A Thread-Specific Example

This first example illustrates the information that you can obtain from the WH_CBT hook. Figure 18-1 shows a screenshot of the application. This application contains a menu bar with the Test menu item, a CreateWnd button, and a MSGBOX button. Each item will aid in our understanding of this hook.

Screenshot of the WH_CBT application

Figure 18-1. Screenshot of the WH_CBT application

Table 18-6 presents the nondefault properties of the form and its controls.

Table 18-6. Nondefault Properties of the Form and Its Controls

Object

Property Name

Property Value

Form1

Name

Form2

Form1

Caption

“WH_CBT Application”

Form1

Top

330

Form1

Left

105

Form1

Height

4710

Form1

Width

7095

Form2

Name

Form1

Form2

Caption

“NEW FORM”

Command Button1

Name

cmdHook

Command Button1

Caption

“hook”

Command Button1

Top

120

Command Button1

Left

120

Command Button1

Height

300

Command Button1

Width

915

Command Button2

Name

cmdUnhook

Command Button2

Caption

“unhook”

Command Button2

Top

780

Command Button2

Left

120

Command Button2

Height

300

Command Button2

Width

915

Command Button3

Name

cmdCreateWnd

Command Button3

Caption

“CreateWnd”

Command Button3

Top

3180

Command Button3

Left

120

Command Button3

Height

315

Command Button3

Width

1395

Command Button4

Name

cmdMsgBox

Command Button4

Caption

“MsgBox”

Command Button4

Top

3900

Command Button4 ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.