Const WM_WINDOWPOSCHANGED =&H47
Сообщение WM_WINDOWPOSCHANGED посылается окну, чьи размеры, позиция и z-порядок были изменены при вызове функции SetWindowPos или ей подобной. Окно получает сообщение через функцию обратного вызова WindowProc
' Используем данное сообщение, ' для перемещения формы только в вертикальном направлении ' Поместите код в модуль, ' т.к. используется функция обратного вызова Public OldWindowProc 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, _ lParam As WINDOWPOS) As Long Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Public Const GWL_WNDPROC = (-4) Type WINDOWPOS hwnd As Long hWndInsertAfter As Long x As Long y As Long cx As Long cy As Long flags As Long End Type Public Function WindowProc(ByVal hwnd As Long, _ ByVal msg As Long, ByVal wParam As Long, _ lParam As WINDOWPOS) As Long Const WM_NCDESTROY = &H82 Const WM_WINDOWPOSCHANGING = &H46 Const WM_WINDOWPOSCHANGED = &H47 Static done_before As Boolean Static left_edge As Integer ' If we're being destroyed, ' restore the original WindowProc. If msg = WM_NCDESTROY Then SetWindowLong _ hwnd, GWL_WNDPROC, _ OldWindowProc End If ' Save the original x value. If msg = WM_WINDOWPOSCHANGED And Not done_before Then left_edge = lParam.x done_before = True End If ' Set the x value. If msg = WM_WINDOWPOSCHANGING Then lParam.x = left_edge WindowProc = CallWindowProc( _ OldWindowProc, hwnd, msg, wParam, lParam) End Function ' Поместите код в событие Form_Load OldWindowProc = SetWindowLong( _ hwnd, GWL_WNDPROC, _ AddressOf WindowProc)