A Thread-Specific Example
To better illustrate this hook’s function and position in the messaging
system, I will modify the thread-specific example for the
WH_CALLWNDPROC hook to incorporate the
WH_CALLWNDPROCRET hook. As Figure 10-2 shows, the interface is similar to the example
in Chapter 9, except for the output.

Figure 10-2. A screenshot of the WH_CALLWNDPROCRET example application
Table 10-1 defines the nondefault properties of the form and its controls.
Table 10-1. Nondefault Property Values for the Form and Its Controls
|
Control |
Property |
Value |
|---|---|---|
|
Form |
Caption |
WH_CALLWNDPROC Hook Test |
|
cmdSendMsg |
Caption |
SendMsg |
|
cmdSendMsgTO |
Caption |
SendMsgTO |
|
cmdPostMessage |
Caption |
PostMessage |
|
cmdPostThreadMsg |
Caption |
PostThreadMsg |
|
cmdSendMsgCB |
Caption |
SendMsgCB |
|
cmdBroadcastMsg |
Caption |
BroadcastMsg |
|
cmdSendDlgMsg |
Caption |
SendDlgMsg |
|
cmdSendMsgNotify |
Caption |
SendMsgNotify |
|
Frame1 |
Caption |
CallWndProc |
|
Text1 |
MultiLine |
True |
The code for this example is very similar to the code for the
WH_CALLWNDPROC example. I will focus the following
discussion on the changes to the code, starting with the
Module2.bas module.
A single private member variable,
bProcRetHook, was added to the code (BAS)
module to hold the hook handle for the
WH_CALLWNDPROCRET hook. The public and
module-level variables declared in the BAS module are now:
Private hProcRetHook As Long Private hProcHook As ...
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