Option Explicit
Private Declare Function SetWindowLongA Lib "User32.dll" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProcA Lib "User32.dll" _
(ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, _
ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_NCLBUTTONDBLCLK As Long = &HA3&
Private Const HTCAPTION As Long = &H2&
Private Const GWL_WNDPROC As Long = (-4)
Private lHwnd As Long
Private lOldFunc As Long
Private lHeight As Single
Private oFrm As Object
Public Sub SubClass _
(ByVal hWnd As Long, ByVal Hght As Single, ByVal Frm As Object)
If lHwnd = 0 Then
lHwnd = hWnd
lHeight = Hght
Set oFrm = Frm
lOldFunc = SetWindowLongA(lHwnd, GWL_WNDPROC, AddressOf lWndProc)
End If
End Sub
Public Sub UnSubClass(dummy As Boolean)
If lHwnd <> 0 Then
Call SetWindowLongA(lHwnd, GWL_WNDPROC, lOldFunc)
lHwnd = 0
lHeight = 0
Set oFrm = Nothing
End If
End Sub
Private Function lWndProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Static x As Long
Dim y As Long
If uMsg = WM_NCLBUTTONDBLCLK Then
If wParam = HTCAPTION Then
y = x Mod 2
x = x + 1
oFrm.Height = Abs(CLng(y <> 0)) * lHeight
End If
End If
lWndProc = CallWindowProcA(lOldFunc, hWnd, uMsg, wParam, lParam)
End Function