Bonjour à tous.

Je vous expose mon problème.
J'avais une application en vb6 qui imprimait un code barre + du texte sur des étiquettes.
J'ai retranscris ce code en vb.net mais il y une instruction qui n'est plus valable et qui m'ennuie fortement.
C'est BarCtrl.PrinterHDC = ObjPrinter.hdc dans la fonction Etikettdrucken

si qqn pouvait me dire comment récupérer le hdc de mon objet printer, ça m'aiderait fortement.

Merci

voici le code simplifé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
Dim ObjPrinter As Printer
Dim BarCtrl As New BARCTRLLib.BarCtrl
 
Function Drucken.click
ObjPrinter.ScaleMode = vbTwips
            If rbtn_Hochformat.Checked = True Then ObjPrinter.Orientation = vbPRORPortrait
            If rbtn_Querformat.Checked = True Then ObjPrinter.Orientation = vbPRORLandscape
            ObjPrinter.Copies = CShort(txt_kopie.Text)
            DruckAbbruch = False
            ObjPrinter.Height = CInt(Höhe)
            ObjPrinter.Width = CInt(breite)
 
            EtikettDrucken()
 
            ObjPrinter.EndDoc()
end function
 
Private Sub EtikettDrucken()
        Dim i As Integer
        Dim ctl As Control
 
        '************************************** Standarttexte und graphiken
        For i = 0 To AnzahlTexte
            If Strings.Left(tText(i), 1) = "[" Then
                '----------- graphik
                For Each ctl In Me.Controls
                    If TypeOf ctl Is PictureBox Then
                        If ctl.Tag.ToString = Val(Strings.Mid(tText(i), 2)).ToString Then
                            ObjPrinter.PaintPicture(CType(ctl, PictureBox).Image, LinkerRand + CInt(tLeft(i)), CSng(tTop(i)))
 
                        End If
                    End If
                Next
            Else
                If Strings.Left(tText(i), 1) = "@" Then
                    If Trim(Strings.Mid(tText(i), 2)) <> "" Then
                        '----------- ean-code
                        BarCtrl.Style = BARCTRLLib.StyleConstants.Ean13
                        BarCtrl.BackColor = vbWhite
                        BarCtrl.BarWidth = 1
                        BarCtrl.Checksum = False
                        BarCtrl.PrinterScaleMode = BARCTRLLib.PrinterScaleModeConstants.Twip   'Twips
                        BarCtrl.PrinterTop = CInt(tTop(i))
                        BarCtrl.PrinterLeft = LinkerRand + CInt(tLeft(i))
                        BarCtrl.PrinterHeight = CInt(tHeight(i))
                        BarCtrl.PrinterWidth = CInt(tWidth(i))
                        BarCtrl.PrinterFontHeight = 200
                        BarCtrl.PrinterBarWidth = CInt(CInt(tWidth(i)) / 100)
                        BarCtrl.BarText = Strings.Mid(tText(i), 2)
 
                        'BarCtrl.PrinterHDC = ObjPrinter.hdc
 
 
                    End If
                Else
                    '----------- text
                    Call tDruckattribute(CInt(i))
                End If
            End If
        Next
        ObjPrinter.NewPage()
    End Sub
 
Private Sub tDruckattribute(ByVal x As Integer)
        ObjPrinter.CurrentX = LinkerRand + CInt(tLeft(x))
        ObjPrinter.CurrentY = CInt(tTop(x))
        ObjPrinter.ForeColor = CInt(tForeColor(x))
        ObjPrinter.FontName = tFontName(x).ToString
        ObjPrinter.FontSize = CInt(tFontSize(x))
        ObjPrinter.FontUnderline = CBool(tFontUnderline(x))
        ObjPrinter.FontBold = CBool(tFontBold(x))
        ObjPrinter.FontItalic = CBool(tFontItalic(x))
        ObjPrinter.Print(tText(x))
 
    End Sub