Api dans Visual Studio 2008 ?

cs_Solher Messages postés 6 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 22 décembre 2008 - 20 nov. 2008 à 11:46
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 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

7 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
20 nov. 2008 à 12:24
ni fait ni a faire....

Long -> Integer
Me.Width / 15 (c'est quoi ce codage porcin ?)
0
cs_Solher Messages postés 6 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 22 décembre 2008
20 nov. 2008 à 12:38
Un code que j'ai trouvé ici... Et de passer de Long a Integer je l'avais deja tester mais ca fesait carrément disparaitre mon formulaire.
0
cs_Solher Messages postés 6 Date d'inscription samedi 15 novembre 2008 Statut Membre Dernière intervention 22 décembre 2008
20 nov. 2008 à 12:41
Ah effectivement ca venait de ce foutu "/ 15". Ca marche. Merci beaucoup

[Résolu]
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
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)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
20 nov. 2008 à 15:00
salut,

en code :



<hr />
'    ARRONDIR LES ANGLES D'UN FORMULAIRE
'    http://www.codyx.org/snippet_arrondir-angles-formulaire_737.aspx#2195
'    Posté par [ PCPT ] le 20/11/2008
<hr />





   
<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 
0
ROGFEDERER Messages postés 4 Date d'inscription mercredi 21 février 2007 Statut Membre Dernière intervention 29 mai 2011
18 août 2009 à 21:58
Bonsoir PCPT,

j'ai donc testé ce code et rien n'y fait.
ma winform n'est toujours pas arrondis !

comment faire alors ?
Solher quel résultat tu obtiens toi ?
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
18 août 2009 à 23:43
ce code m'a pourtant l'air nickel.


Renfield - Admin CodeS-SourceS - MVP Visual Basic
0
Rejoignez-nous