This Works
Code:Option Explicit Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private 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 Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private 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 Private Const WM_WINDOWPOSCHANGING = &H46 Dim hDefWinProc As Long Public Sub Subclass(hwnd As Long) hDefWinProc = SetWindowLong(hwnd, -4, AddressOf WndProc) End Sub Public Function WndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim apiNewPosition As WINDOWPOS WndProc = CallWindowProc(hDefWinProc, hwnd, wMsg, wParam, lParam) If wMsg = WM_WINDOWPOSCHANGING Then Call CopyMemory(apiNewPosition, ByVal lParam, LenB(apiNewPosition)) If apiNewPosition.x > 200 Then _ apiNewPosition.x = 200 If apiNewPosition.y > 200 Then _ apiNewPosition.y = 200 Call CopyMemory(ByVal lParam, apiNewPosition, LenB(apiNewPosition)) End If End Function




Reply With Quote