RuntimeCreateGetMessageHook

Creates a fresh IGetMessageHook for filtering Windows messages destined for a chosen window and (optionally) its descendants.

Syntax: RuntimeCreateGetMessageHook() As IGetMessageHook

The returned hook starts dormant. Subscribe a callback for one or more message types with RegisterMessage, then call Start to activate the subscriptions and Stop to remove them.

Example

Const WM_LBUTTONDOWN = &H201

Sub HookClicks()
    Dim Hook As IGetMessageHook = RuntimeCreateGetMessageHook()
    Hook.RegisterMessage Me.hWnd, AllDescendants, _
                         WM_LBUTTONDOWN, AddressOf OnLButtonDown
    Hook.Start
End Sub

See Also