- Код: Выделить всё
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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 Long
Public Const WM_GETMINMAXINFO = &H24
Public Type POINTAPI
x As Long
y As Long
End Type
Public Const GWL_WNDPROC = (-4)
Public Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End Type
Global MMI As MINMAXINFO
Global Prev_hWnd As Long
Function WinAPI_GMMI(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_GETMINMAXINFO Then
Call CopyMemory(MMI, lParam, Len(MMI))
MMI.ptMinTrackSize.y = 100
MMI.ptMinTrackSize.x = 100
Else
WinAPI_GMMI = CallWindowProc(Prev_hWnd, hWnd, Msg, wParam, lParam)
End If
End Function
Sub SubClass()
Prev_hWnd = SetWindowLong(Form1.hWnd, GWL_WNDPROC, AddressOf WinAPI_GMMI)
End Sub
Sub UnSubClass()
Call SetWindowLong(Form1.hWnd, GWL_WNDPROC, Prev_hWnd)
End Sub
Этот код должен, обрабатывать сообщение GETMINMAXINFO и задавать минимальный размер окна.
Но, увы, код не работает...
Мужики, подскажите, почему код не работает?
Заранее благодарен.