S.O.S "Rotation" !!!

liban123 Messages postés 19 Date d'inscription mercredi 9 février 2005 Statut Membre Dernière intervention 14 mars 2005 - 10 mars 2005 à 14:59
liban123 Messages postés 19 Date d'inscription mercredi 9 février 2005 Statut Membre Dernière intervention 14 mars 2005 - 11 mars 2005 à 07:41
Bonjour a tous!

Comme on ne peut pas dessiner un rectangle comme on le souhaite en Visual Basic, je vourai savoir si il est possible d'utiliser la fonction "Rotation" pour pouvoir fair pivoter un rectangle d'un angle que l'on souhaite.

Je débute en Visual Basic et je suis vraiment coincé...

Je vous remerci énormément!

Nab

2 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
10 mars 2005 à 17:03
Option Explicit


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 ' ALTERNATE and WINDING are
Const WINDING = 2 ' constants for FillMode.
Const BLACKBRUSH = 4 ' Constant for brush type.


Private Sub Command1_Click()
Dim poly(4) As COORD
Dim NumCoords As Long
Dim hBrush As Long
Dim hRgn As Long

Picture1.Cls

NumCoords = 4


Picture1.ScaleMode = vbPixels

poly(0).x = 80
poly(0).y = 50
poly(1).x = 150
poly(1).y = 70
poly(2).x = 100
poly(2).y = 220
poly(3).x = 30
poly(3).y = 200

Polygon Picture1.hdc, poly(0), NumCoords


hBrush = GetStockObject(BLACKBRUSH)


hRgn = CreatePolygonRgn(poly(0), NumCoords, ALTERNATE)

If hRgn Then FillRgn Picture1.hdc, hRgn, hBrush

DeleteObject hRgn

End Sub

j'ai pas trouvé comment on fait pour avoir d'autres couleurs, en changeant le paramètre j'arrive à avoir du noir rempli ou pas et du rouge seulement en bordure.

Daniel
0
liban123 Messages postés 19 Date d'inscription mercredi 9 février 2005 Statut Membre Dernière intervention 14 mars 2005
11 mars 2005 à 07:41
Merci pour ta réponse!

Dis moi, comment tu t'y prend pour changer la couleur des bordures?

Merci Daniel

Nab
0
Rejoignez-nous