Factom, a module: The form of the form is 0, the form code is 0, the form code is as follows: Option ExplicitPrivate Type Rect Left As Long Top as long Right As long bottom as longend typeprivate declare function getWindowRect lib "User32 "(ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function FindWindow Lib" user32 "Alias" FindWindowA "(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib" user32 "Alias" FindWindowExA "(ByVal HWND1 As Long, Byval Hwnd2 As String, BYVAL LPSZ2 AS STRING AS Longprivate Declare Function GetDesktopWindow Lib "User32" () As long
Private sub mess1_click () me.windowstate = 2END SUB
Private submmand2_click () unload mend Sub
Private Sub Form_Load () Dim hTaskBar As Long hTaskBar = FindWindow ( "Shell_TrayWnd", vbNullString) Debug.Print hTaskBar Dim RC As RECT Dim i As Long i = GetWindowRect (hTaskBar, RC) Dim taskheight As Long taskheight = RC.Bottom - RC .Top 'task bar height i = GetWindowRect (GetDesktopWindow, RC) Dim maxwidth As Long Dim maxheight As Long maxwidth = RC.Right - RC.Left' Get the screen width maxheight = RC.Bottom - RC.Top - taskheight 'screen height - Task Bar Height Lockwindow Me.hwnd,, Maxwidth, Maxheightens Sub
Module code: Option Explicit
Public Type Pointapi X as long y as longed type
Public Type MinMaxInfo PTReServed As Pointapi PtmaxSize As Pointapi PtmaxPosition As Pointapi PtmaxTracksize As Pointapi PtmaxTracksize As Pointapiend Type
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public 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 LongPublic Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Declare Function SendMessage Lib " User32 "Alias" SendMessagea "(Byval Hwnd As Long, Byval WMSG As Long, Byval WParam As Long, LParam as Any) As longpublic const wm_getminMaxInfo = & H24PUBLIC Const GWL_WndProc = -4
Global lpPrevWndProc As LongPublic procOld As LongPublic udtMMI As MINMAXINFO Public Function WindowProc (ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Select Case iMsg Case WM_GETMINMAXINFO Dim udtMINMAXINFO As MINMAXINFO CopyMemory udtMINMAXINFO, ByVal lParam , 40 & With udtMINMAXINFO .ptMaxSize.x = udtMMI.ptMaxSize.x .ptMaxSize.y = udtMMI.ptMaxSize.y .ptMaxPosition.x = 0 .ptMaxPosition.y = 0 .ptMaxTrackSize.x = .ptMaxSize.x .ptMaxTrackSize.y = .ptMaxSize.y .ptMinTrackSize.x = udtMMI.ptMinTrackSize.x .ptMinTrackSize.y = udtMMI.ptMinTrackSize.y Debug.Print .ptMaxSize.x & "," & .ptMaxSize.y End With CopyMemory ByVal lParam, udtMINMAXINFO, 40 & WindowProc = False exit function end select windowproc = CallWindowProc (Procold, HWND, IMSG, WPARAM, LPARAM) End Function