Maximiser un userform à l'initialisation
j'ai déjà déclaré les fonctions API et une fonction "InitMaxMin" dans un module standard, aussi j'ai définie la fonction resize et fini de mon userform
les petites icones de réduction et d'agrandissement marchent très bien, bref Max Min Resize fonctionnent bien.
je voulais seulement maximiser mon userfom à l'initialisation
dans un module standard ( mon code ):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Option Explicit
' declaration API pour réduire, agrandir,resize
Public Declare Function FindWindowA& Lib "user32" (ByVal lpClassName$, ByVal lpWindowName$)
Public Declare Function GetWindowLongA& Lib "user32" (ByVal hwnd&, ByVal nIndex&)
Public Declare Function SetWindowLongA& Lib "user32" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
' Déclaration des constantes
Public Const GWL_STYLE As Long = -16
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_FULLSIZING = &H70000
'Attention, envoyer après changement du caption de l'UF
Public Sub InitMaxMin(mCaption As String, Optional Max As Boolean = True, Optional Min As Boolean = True _
, Optional Sizing As Boolean = True)
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, mCaption)
If Min Then SetWindowLongA hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) Or WS_MINIMIZEBOX
If Max Then SetWindowLongA hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) Or WS_MAXIMIZEBOX
If Sizing Then SetWindowLongA hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) Or WS_FULLSIZING
End Sub
'Application.DisplayFullScreen = True |
maximiser un userform à l'initialisation
@arosec
ça marche pas, parce que dans userform-resize() j'ai déclaré des variables qui sont fonction de Me.Height et Me.Width, donc j'avais un débogage dans ces deux lignes.
voici mon code:
Code:
1 2 3 4 5 6 7 8
| Private Sub UserForm_Resize()
Dim RtL As Single, RtH As Single
If Me.Width < 300 Or Me.Height < 200 Or Fini Then Exit Sub
RtL = Me.Width / Lg
RtH = Me.Height / Ht
Me.Zoom = IIf(RtL < RtH, RtL, RtH) * 100
End Sub |