' Routine within MsgHook which calls default window procedure
Declare Function InvokeWindowProc Lib "MsgHook.vbx" (ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Long
' We want to catch messages causing non-client repaints
Const WM_NCPAINT = &H85
Const WM_NCACTIVATE = &H86
Const WM_SIZE = &H5
' Store Caption as a string
Dim Kaption As String
Sub Form_Load ()
' Set Caption to "", storing whatever was set at design
Kaption = Me.Caption
Me.Caption = ""
' Setup MsgHook control
MsgHook.HwndHook = Me.hWnd
MsgHook.Message(WM_NCPAINT) = True
MsgHook.Message(WM_NCACTIVATE) = True
MsgHook.Message(WM_SIZE) = True
End Sub
Sub MsgHook_Message (Msg As Integer, wParam As Integer, lParam As Long, Result As Long)
Static PrevState As Integer
' Fire default window procedure before processing
' any of the messages we're interested in for this
' task.
Result = InvokeWindowProc(MsgHook.HwndHook, Msg, wParam, lParam)
' Check which message arrived, and act accordingly.