A Thread-Specific Example
The example presented here, which is shown in Figure 11-2, will build on what you learned in Chapter 9 and Chapter 10. By following
this example, you will see the differences between the
WH_CALLWNDPROC,
WH_CALLWNDPROCRET, and
WH_GETMESSAGE hooks. This example installs the
three hooks. Now, when you click the PostMessage and PostThreadMsg
buttons, you will see the WH_GETMESSAGE hook
display messages in the text box.

Figure 11-2. Screenshot of example application
Table 11-1 lists the nondefault properties of the form and its controls.
You use this application in the same way you used the sample
applications in the previous two chapters. Click the hook button to
install all three hooks, and then click each of the lower buttons
shown in Figure 11-2 to send and post the
WM_NULL message. The text box will indicate which
hook intercepted the WM_NULL message, as well as
the available parameters for that hook. There is no difference from
the previous applications in output displayed when you click the
SendMessage type buttons. When you click the PostMessage and
PostThreadMsg buttons, the WH_GETMESSAGE hook now
displays a line of text indicating that it has intercepted the posted
message.
Table 11-1. Nondefault Properties of the Form and Its Controls
|
Object Type |
Property Name |
Property Value |
|---|---|---|
|
Form |
Name |
Form2 |
|
Form |
Caption |
“WH_GETMESSAGE Hook Test” |
|
Form |
Top |
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