Bonjour , j'ai trouvé sur le net un code permettant de dessiner un triangle , mais le soucis c'est qu'il y a aucun commentaire , et j'aimerai transformer ce triangle en un sablier , 2 triangles symétrique ayant un sommet en commun ...
merci d'avance
amicalement lucas
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
Private Type COORD
    x As Long
    y As Long
End Type
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Const ALTERNATE = 1
Const WINDING = 2
Const BLACKBRUSH = 4
Private Sub Form_Paint()
    Dim poly(1 To 4) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
    Me.Cls
    NumCoords = 2
    Me.ScaleMode = vbPixels
    poly(1).x = Form1.ScaleWidth / 2
    poly(1).y = Form1.ScaleHeight / 2
    poly(2).x = Form1.ScaleWidth / 4
    poly(2).y = 3 * Form1.ScaleHeight / 4
    poly(3).x = 3 * Form1.ScaleWidth / 4
    poly(3).y = 3 * Form1.ScaleHeight / 4
    Polygon Me.hdc, poly(1), NumCoords
    hBrush = GetStockObject(BLACKBRUSH)
    hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
    If hRgn Then FillRgn Me.hdc, hRgn, hBrush
    DeleteObject hRgn
End Sub
Private Sub Form_Resize()
    Form_Paint
End Sub