Boutons réduire et agrandir dans un userform

Pour avoir les boutons réduire et agrandir dans un userform coller dans un module standard du userform

Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = (-16)  'The offset of a window's style
Private hWnd, IStyle
Public Sub toto(F As Object)
    hWnd = FindWindow(vbNullString, F.Caption)
    IStyle = GetWindowLong(hWnd, GWL_STYLE) Or &H70000
    SetWindowLong hWnd, GWL_STYLE, IStyle
End Sub

puis Coller toto me

dans private sub userform_inizialize

Bonjour Chtimili

Auriez vous svp ce code pour une version 64 bits ?

Je vous remercie pour votre aide.

Bonjour,

Version 64 bits :

Private Declare PtrSafe Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = (-16)  'The offset of a window's style
Private hWnd, IStyle

Public Sub toto(F As Object)
    hWnd = FindWindow(vbNullString, F.Caption)
    IStyle = GetWindowLong(hWnd, GWL_STYLE) Or &H70000
    SetWindowLong hWnd, GWL_STYLE, IStyle
End Sub

Bonjour

Au top merci beaucoup

Bonjour,

c'est comme même dingue que sous Windows, avec une application MS, on soit obligé à tant de choses pour arriver à un fonctionnement des plus normale d'une fenêtre !

Mais bon, c'est comme ça !

Merci pour l'astuce, il existe des codes sur le net où en plus de ceci, il y a un effet "zoom" sur les contrôles afin de garder une proportion de présentation.

@ bientôt

LouReeD

Rechercher des sujets similaires à "boutons reduire agrandir userform"