A Thread-Specific Example

The example presented here is a thread-specific example that installs the WH_SHELL hook and displays shell notification messages as they occur. Figure 17-3 provides a screenshot of the example application.

Screenshot of example application

Figure 17-3. Screenshot of example application

Table 17-4 presents the nondefault properties of the form and its controls.

Using the Application

The application works like the previous examples. Click the hook button to install the hook and the unhook button to remove the hook. The hook and unhook buttons in the SHELL frame deal with the WH_SHELL hook. The following three extra buttons are included as well:

Create Wnd

Creates and displays a form using the code Load Form1.

TaskBar Title

Changes the text in the window title bar from “WH_SHELL Example” to “Title of Window Has Changed”. Note that changing the top-level unowned window’s title text causes the same text to be displayed in the task bar for this window.

MsgBox

Displays a simple message box.

Table 17-4. Nondefault Properties of the Form and Its Controls

Object

Property Name

Property Value

Form1

Name

Form2

Form1

Caption

“WH_SHELL Example”

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 ...

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.