cs_Solher
Messages postés6Date d'inscriptionsamedi 15 novembre 2008StatutMembreDernière intervention22 décembre 2008
-
20 nov. 2008 à 11:46
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 2021
-
18 août 2009 à 23:43
Salut !
J'ai un problème avec le Api dans Visual Studio 2008.
En fait j'ai copié un code pour modifier mon form en rectangle avec les bords arrondis.
Dans le formulaire :
Dim lReigon As Long
Dim lResult As Long
lReigon = CreateRoundRectRgn(0, 0, Me.Width / 15, Me.Height / 15, 15, 15)
'Vous pouvez modifier les deux 15 a la fin pour arrondir plus ou moins
lResult = SetWindowRgn(Me.Handle, lReigon, True)
En remplacant "Me.hWnd" par "Me.Handle"
Dans un module :
Declare Function CreateRoundRectRgn Lib "gdi32" (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
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Pourtant, mon form ne change pas et reste rectangulaire. Ou est l'erreur ?
Merci d'avance
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 20 nov. 2008 à 13:12
ce /15 a une raison d'être, il ne faut pas le recopier sans se poser de question.
en VB6, Width renvoie une valeur en twips. un Twips, dans un bon paquet de configurations, equivaut à 15 pixels.
.Net joues directement avec des pixels ; il ne faut donc plus diviser par 15
(bien qu'il vaille mieux de toutes facon utiliser Screen.TwipsPerPixelsX ou TwipsPerPixelsY)
Vous n’avez pas trouvé la réponse que vous recherchez ?
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", SetLastError:=True)>
Private Function CreateRoundRectRgn(ByVal X1 As Int32, ByVal Y1 As Int32, ByVal X2 As Int32, ByVal Y2 As Int32, ByVal X3 As Int32, ByVal Y3 As Int32) As IntPtr
End Function
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", SetLastError:=True)> Private Function DeleteObject(ByVal hObject As IntPtr) As Int32
End Function
<System.Runtime.InteropServices.DllImportAttribute("user32.dll", SetLastError:=True)> Private Function SetWindowRgn(ByVal hwnd As IntPtr, ByVal hRgn As IntPtr, ByVal bRedraw As Boolean) As Int32
End Function
Public Sub RoundCorners(ByRef oFrm As System.Windows.Forms.Form, Optional ByVal Angle As System.Byte = 15)
With oFrm
Dim lRet As IntPtr = CreateRoundRectRgn(0, 0, .Width, .Height, Angle, Angle)
SetWindowRgn(.Handle, lRet, True)
DeleteObject(lRet)
End With
End Sub
++
<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp