# RuntimeCreateGetMessageHook
{: .no_toc }

Creates a fresh [**IGetMessageHook**](/tB/Modules/HiddenModule/index.md#igetmessagehook-interface) 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**](/tB/Modules/HiddenModule/RegisterMessage.md), then call [**Start**](/tB/Modules/HiddenModule/Start.md) to activate the subscriptions and [**Stop**](/tB/Modules/HiddenModule/Stop.md) to remove them.

> [!WARNING] BETA 1045
> Assigning the result to a **Variant** without **Set**, as in `V = RuntimeCreateGetMessageHook()`, ends the program with an access violation, in a 32-bit and a 64-bit build alike. Assign it with **Set**, or to a variable declared **As IGetMessageHook**.

### Example

```tb check_build inherits=Form
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

- [IGetMessageHook interface](/tB/Modules/HiddenModule/index.md#igetmessagehook-interface)
- [GetMessageHookHelper module](/tB/Modules/HiddenModule/index.md#getmessagehookhelper-module)
