Stop Form Resizing
Subclass you form to stop users from resizing below a certain limit! If you hate the generic two-liners "If Me.Height
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Public Sub Hook(frm As Form) ' HOOK! Place the Call Hook(Me) code in your desired form lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, AddressOf WindowProc) End Sub Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long ' WINDOWPROC! Does the actual subclassing If uMsg = WM_GETMINMAXINFO Then Dim MinMax As MINMAXINFO CopyMemory MinMax, ByVal lParam, Len(MinMax) MinMax.ptMinTrackSize.X = 100 ' Set this to the min width in PIXELS (not twip!) MinMax.ptMinTrackSize.Y = 100 ' Set this to the min height in PIXELS (not twip!) CopyMemory ByVal lParam, MinMax, Len(MinMax) Else WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam) End If End Function Public Sub Unhook(frm As Form) ' UNHOOK! Place the code Call Unhook(Me) in your form's Unload() event SetWindowLong frm.hwnd, GWL_WNDPROC, lpPrevWndProc End Sub
Original Comments (3)
Recovered from Wayback Machine