Dim last_size_X As Long Dim last_size_Y As Long Private Sub Form_Load() last_size_X = Me.Width last_size_Y = Me.Height End Sub Private Sub Form_Resize() If Me.Width > last_size_X Or Me.Height > last_size_Y Then Me.Width = last_size_X Me.Height = last_size_Y Else last_size_X = Me.Width last_size_Y = Me.Height End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit Public Const GWL_WNDPROC As Long = -4 Private Const WM_GETMINMAXINFO As Long = &H24 Public SauveAdressWinProc As Long Public MinX As Long Public MinY As Long Private Type POINTAPI x As Long y As Long End Type Private Type MINMAXINFO ptReserved As POINTAPI ptMaxSize As POINTAPI ptMaxPosition As POINTAPI ptMinTrackSize As POINTAPI ptMaxTrackSize As POINTAPI End Type Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _ (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Public Function MaWinProc(ByVal hwnd As Long, ByVal uMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long If uMsg = WM_GETMINMAXINFO Then Dim MinMax As MINMAXINFO CopyMemory MinMax, ByVal lParam, Len(MinMax) MinMax.ptMinTrackSize.x = MinX MinMax.ptMinTrackSize.y = MinY CopyMemory ByVal lParam, MinMax, Len(MinMax) MaWinProc = 1 Exit Function End If MaWinProc = CallWindowProc(SauveAdressWinProc, hwnd, uMsg, wParam, lParam) End Function
Private Sub Form_Load() MinX = 9600 / Screen.TwipsPerPixelX MinY = 7125 / Screen.TwipsPerPixelY SauveAdressWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC) Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf MaWinProc) End Sub 'pour terminer proprement le programme: Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Call SetWindowLong(Me.hWnd, GWL_WNDPROC, SauveAdressWinProc) End Sub