Hi all. I have a form embedded in a VB Add-In dll. I'm trying to subclass the form to handle WM_GETMINMAXINFO so the form cannot be resized below a certain point. Here is the code:

'modGlobal

public g_OldWndProc as Long

public Sub Subclass(hwnd as Long)
g_OldWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf NewWndProc)
End Sub

public Sub UnSubclass(hwnd as Long)
SetWindowLong hwnd, GWL_WNDPROC, g_OldWndProc
End Sub

public Function NewWndProc(hwnd as Long, wMsg as Long, wParam as Long, lParam as Long) as Long
If wMsg = WM_GETMINMAXINFO then
Dim mmi as MINMAXINFO

CopyMemory mmi, byval lParam, len(mmi)
mmi.ptMinTrackSize.x = 400
mmi.ptMinTrackSize.y = 400
CopyMemory byval lParam, mmi, len(mmi)
NewWndProc = false
Exit Function
End If
NewWndProc = CallWindowProc(g_OldWndProc, hwnd, wMsg, wParam, lParam)
End Function

'frmMenuUI
private Sub Form_Load()
me.Icon = LoadResPicture(101, vbResIcon)

Subclass me.hwnd
End Sub

private Sub Form_Resize()
Dim rcClient as RECT

GetClientRect me.hwnd, rcClient
With picMenuEditor
.Left = 0
.Top = 0
.Width = rcClient.Right
.Height = rcClient.Bottom - 180
End With
End Sub

private Sub Form_Unload(Cancel as Integer)
UnSubclass me.hwnd
End Sub


The Add-in compiles fine, but when I try to load the form in VB, VB freezes, and my form never loads. My code looks fine, as far as I can tell, though obviously something is wrong...

Thanks in advance for any help.