' Look for WM_SHOWWINDOW.
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg _
As Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
Const WM_NCDESTROY = &H82
Const SW_OTHERUNZOOM = 4
Const SW_OTHERZOOM = 2
Const SW_PARENTCLOSING = 1
Const SW_PARENTOPENING = 3
Const WM_SHOWWINDOW = &H18
Dim reason As String
' If we're being destroyed,
' restore the original WindowProc.
If msg = WM_NCDESTROY Then
SetWindowLong _
hwnd, GWL_WNDPROC, _
OldWindowProc
End If
If msg = WM_SHOWWINDOW Then
' See why the visibility is changing.
Select Case lParam
Case SW_OTHERZOOM
reason = "SW_OTHERZOOM"
Case SW_PARENTCLOSING
reason = "SW_PARENTCLOSING"
Case SW_PARENTOPENING
reason = "SW_PARENTOPENING"
Case WM_SHOWWINDOW
reason = "WM_SHOWWINDOW"
Case Else
reason = "<unknown>"
End Select
Form1.VisibleEvent CBool(wParam), reason
End If
NewWindowProc = CallWindowProc( _
OldWindowProc, hwnd, msg, wParam, _
lParam)
End Function
|