I`m trying to subclass wm_size event .. (trying to stop resizing when too small)
anyways .. my whole app crashes .. here`s the code ...



.bas
Option Explicit
'messages to intercept
Public Const WM_SIZE = &H5
Public Const WM_PAINT = &HF
Public Const GWL_WNDPROC = (-4) 'subclassing routine
Public OldProc As Long

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long)
Private Declare Function GetClientRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
---------------------------------------------------------
Public Function WndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

If wMsg = WM_SIZE Then
PostMessage hwnd, WM_PAINT, 0, 0
MsgBox("resized")
'don`t do anything .... just passes along
End If
'pass other messages
WndProc = CallWindowProc(OldProc, hwnd, wMsg, wParam, lParam)
End Function

-------------------------------------------------
form

Public Sub Form_Load()
OldProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
End sub
Private Sub form_unload(Cancel As Integer)
'finish subclassing
retval = SetWindowLong(Me.hwnd, GWL_WNDPROC, OldAdress)
End sub

anybody has an idea ?