Duke49
Messages postés552Date d'inscriptionjeudi 12 octobre 2006StatutNon membreDernière intervention24 janvier 2023
-
26 mars 2009 à 00:44
Duke49
Messages postés552Date d'inscriptionjeudi 12 octobre 2006StatutNon membreDernière intervention24 janvier 2023
-
26 mars 2009 à 10:41
Coucou,
2 petites questions.
1)
j'ai besoin d'une aide pour positionner une région autour d'un objet Label.
La region doit faire la taille de mon Label et l'entourer de 3 pixels (avec bout arrondi de 5).
Voici mon bout de code, je galère, merci.
Dim hregion As Long
Dim hbrush As Long
With objFormHdc
.AutoRedraw = True
.ScaleMode = vbTwips
.Cls
hregion = CreateRoundRectRgn(lzX-3, lzY+3, lzWidth, lzHeight, 5, 5)
hbrush = CreateSolidBrush(vbYellow)
DeleteObject SelectObject(.hdc, hbrush)
PaintRgn .hdc, hregion
End With
2)
Est t'il nécessaire de faire un DeleteObject sur le hregion ? Ça libérerai sa mémoire ?
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 26 mars 2009 à 08:10
Private Declare Function CreateRoundRectRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Function FillRgn Lib "gdi32.dll" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim hRgn As Long
Dim hBrush As Long
hRgn = CreateRoundRectRgn(Label1.Left - 3, Label1.Top - 3, Label1.Left + Label1.Width + 5, Label1.Top + Label1.Height + 5, 5, 5)
hBrush = CreateSolidBrush(vbYellow)