这个放模块中:Option ExplicitPublic OldWindowProc As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)
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 Const WM_GETMINMAXINFO = &H24
Type POINTAPI
x As Long
y As Long
End Type
Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End TypePublic Function SubClass1_WndMessage(ByVal hwnd As Long, ByVal Msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
If Msg = WM_GETMINMAXINFO Then
Dim MinMax As MINMAXINFO
CopyMemory MinMax, ByVal lp, Len(MinMax)
MinMax.ptMinTrackSize.x = 3975 \ Screen.TwipsPerPixelX
MinMax.ptMinTrackSize.y = 1740 \ Screen.TwipsPerPixelY
MinMax.ptMaxTrackSize.x = Screen.Width \ Screen.TwipsPerPixelX \ 2
MinMax.ptMaxTrackSize.y = 3480 \ Screen.TwipsPerPixelY
CopyMemory ByVal lp, MinMax, Len(MinMax)
SubClass1_WndMessage = 1
Exit Function
End If
SubClass1_WndMessage = CallWindowProc(OldWindowProc, hwnd, Msg, wp, lp)
End Function 这个放窗体代码区:Option Explicit
Private Const GWL_WNDPROC = (-4)Private Sub Form_Load()
OldWindowProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage)
End SubPrivate Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, OldWindowProc)
End Sub
Private Sub Form_Resize()
Me.Width = 800 * 15
Me.Height = 600 * 15
End Sub 效果不佳,如果想不被改大小,还是建议把样式设置为fixed dialog,如果你还需要最小化按钮,直接把MinButton属性设置为True即可,最大化按钮把MaxButton设置为True。