Option Explicit Private Const PS_ENDCAP_SQUARE = &H100 '# Bout carré pour la ligne Private Const PS_ENDCAP_FLAT = &H200 '# Bout Plat pour la ligne Private Const PS_ENDCAP_ROUND = &H0 '# Bout Rond pour la ligne Private Const PS_GEOMETRIC = &H10000 '# Utiliser les valeurs précisée et non celles par default Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function ExtCreatePen Lib "gdi32" (ByVal dwPenStyle As Long, ByVal dwWidth As Long, lplb As LOGBRUSH, ByVal dwStyleCount As Long, lpStyle As Long) As Long Private Type LOGBRUSH lbStyle As Long lbColor As Long lbHatch As Long End Type Private Sub Picture1_Paint() Picture1.DrawWidth = 15 Picture1.ScaleMode = vbPixels '# Ligne classique : bouts ronds ! Picture1.Line (10, 10)-(100, 100) Dim Brush As LOGBRUSH Dim Pen As Long Dim OldPen As Long '# via le Brush, on peut controler certains parametres du tracé (couleur...) '# On crée un nouveau crayon Pen = ExtCreatePen(PS_ENDCAP_FLAT Or PS_GEOMETRIC, Picture1.DrawWidth, Brush, 0, ByVal 0&) '# On sauvegarde le crayon utilisé, et on affecte le crayon precedemment crée OldPen = SelectObject(Picture1.hdc, Pen) '# Cette ligne a les bouts plats Picture1.Line (110, 110)-(200, 200) '# On rattache l'ancien crayon au PictureBox, et on supprime le crayon crée SelectObject Picture1.hdc, OldPen DeleteObject Pen End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question