'Declarations
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen 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 Type
'Subclassing code. Change the ptMinTrackSize values to what you want
Public 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)
' This is where you set the values of the MinX,MinY,MaxX, and MaxY
' The values placed in the structure must be in pixels. The values
' normally used in Visual Basic are in twips. The conversion is as follows:
' pixels = twips\twipsperpixel
MinMax.ptMinTrackSize.x = 5535 \ Screen.TwipsPerPixelX
MinMax.ptMinTrackSize.Y = 3000 \ Screen.TwipsPerPixelY
MinMax.ptMaxTrackSize.x = Screen.Width \ Screen.TwipsPerPixelX '\ 2
MinMax.ptMaxTrackSize.Y = Screen.Height \ 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