WM_GETMINMAXINFO
The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size. WM_GETMINMAXINFO 
lpmmi = (LPMINMAXINFO) lParam; // address of structure 
 
Parameters
lpmmi 
Value of lParam. Pointer to a MINMAXINFO structure that contains the default maximized position and dimensions, and the default minimum and maximum tracking sizes. An application can override the defaults by setting the members of this structure. 
Return Values
If an application processes this message, it should return zero. Res
The maximum tracking size is the largest window size that can be produced by using the borders to size the window. The minimum tracking size is the smallest window size that can be produced by using the borders to size the window. QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.MINMAXINFO
The MINMAXINFO structure contains information about a window's maximized size and position and its minimum and maximum tracking size. typedef struct tagMINMAXINFO {  // mmi 
    POINT ptReserved; 
    POINT ptMaxSize; 
    POINT ptMaxPosition; 
    POINT ptMinTrackSize; 
    POINT ptMaxTrackSize; 
} MINMAXINFO; 
 
Members
ptReserved 
Reserved; do not use. 
ptMaxSize 
Specifies the maximized width (point.x) and the maximized height (point.y) of the window. 
ptMaxPosition 
Specifies the position of the left side of the maximized window (point.x) and the position of the top of the maximized window (point.y). 
ptMinTrackSize 
Specifies the minimum tracking width (point.x) and the minimum tracking height (point.y) of the window. 
ptMaxTrackSize 
Specifies the maximum tracking width (point.x) and the maximum tracking height (point.y) of the window. 
QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.

解决方案 »

  1.   

    '-------------------------------------------------------
    ' 将以下代码放到你的表单代码中
    '-------------------------------------------------------
    Option ExplicitPrivate Const GWL_WNDPROC As Long = (-4&)Private Sub Form_Load()
       Call LockWindow(400,250)
    End SubPrivate Sub Form_Unload()
       If procOld > 0 Then
          Call SetWindowLong(hWnd, GWL_WNDPROC, procOld)
       End If
    End SubPrivate Function LockWindow(Optional MinWidth As Long, Optional MinHeight As Long, Optional MaxWidth As Long, Optional MaxHeight As Long) As Boolean
       If procOld > 0 Then
          Call SetWindowLong(hWnd, GWL_WNDPROC, procOld)
       End If
       
       With udtMMI
          '指定窗体的最小宽度
          If MinWidth = 0 Then
             .ptMinTrackSize.X = 0
          Else
             .ptMinTrackSize.X = MinWidth
          End If
          
          '指定窗体的最小高度
          If MinHeight = 0 Then
             .ptMinTrackSize.Y = 0
          Else
             .ptMinTrackSize.Y = MinHeight
          End If
          
          '指定窗体的最大宽度
          If MaxWidth = 0 Then
             .ptMaxSize.X = Screen.Width \ Screen.TwipsPerPixelX
          Else
             .ptMaxSize.X = MaxWidth
          End If
          
          '指定窗体的最大高度
          If MaxHeight = 0 Then
             .ptMaxSize.Y = Screen.Height \ Screen.TwipsPerPixelY
          Else
             .ptMaxSize.Y = MaxHeight
          End If
       End With
       procOld = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
    End Function'-------------------------------------------------------
    ' 将以下代码放到一个模组文件中
    '-------------------------------------------------------
    Option ExplicitPublic 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 Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal cBytes&)
    Public Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
    Public Type MINMAXINFO
       ptReserved As POINTAPI
       ptMaxSize As POINTAPI
       ptMaxPosition As POINTAPI
       ptMinTrackSize As POINTAPI
       ptMaxTrackSize As POINTAPI
    End TypePublic procOld As LongPublic Function WindowProc(ByVal hWnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
       Select Case iMsg
          Case &H24 'WM_GETMINMAXINFO=&H24
             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
             End With
             CopyMemory ByVal lParam, udtMINMAXINFO, 40&
             WindowProc = False
             Exit Function
       End Select
       WindowProc = CallWindowProc(procOld, hWnd, iMsg, wParam, lParam)
    End Function
      

  2.   

    http://www.csdn.net/expert/topic/841/841964.xml?temp=.7871515