A Thread-Specific Example
The example application presented here is similar to previous examples. The application
provides one button for installing the
WH_MSGFILTER hook and one for uninstalling the
hook. After you install the hook, messages that the
WH_MSGFILTER hook intercepts are displayed, along
with the members of the MSG structure for each
message, as Figure 15-8 shows.

Figure 15-8. Screenshot of the WH_MSGFILTER application
Table 15-1 presents the nondefault properties of the form and its controls.
Three items are present in the sample application to test this hook.
The first is a menu that contains a single menu item. When the hook
is installed and this menu is used, the hook will intercept messages
related to actions performed on the menu and display them in the text
box provided. Menu messages to the filter function with a code of
MSGF_MENU. As a note, you can right-click the text
box or the window title bar to produce a pop-up menu. The hook also
will intercept messages related to these types of menus.
The second item is a button that displays a message box. When the
message box is displayed, the WH_MSGFILTER hook
will intercept messages related to the message box. Message box
messages are sent to the filter function with a code of
MSGF_DIALOGBOX. When the user clicks the OK
button, the hook ceases to intercept messages for the message box.
Table 15-1. Nondefault Properties ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access