Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

Subclassing & Hooking with Visual Basic offers developers a unique way to customize Windows behavior.Windows is a message-based system. Every action you request creates one or more messages to carry out the action. These messages are passed between objects and carry with them information that gives the recipient more detail on how to interpret and act upon the message.With Subclassing and the Windows hooking mechanism ("hooks"), you can manipulate, modify, or even discard messages bound for other objects within the operating system, in the process changing the way the system behaves. What kinds of results can you achieve using the power of subclassing and hooking? Here are just a few of the possibilities:

  • Determine when a window is being activated or deactivated and respond to this change.
  • Display descriptions of menu items as the mouse moves across them.
  • Disallow a user to move or resize a window.
  • Determine where the mouse cursor is and respond accordingly.
  • Determine when the display resolution has been changed.
  • Monitor the system for a low system resource condition.
  • Modify or disallow keystrokes sent to a window or a control.
  • Create an automated testing application.
  • Determine when an application is idle.
Along with this power comes responsibility; Windows is very unforgiving if subclassing and hooking are used incorrectly. Subclassing & Hooking with Visual Basic demonstrates the various techniques for intercepting messages bound for one or more windows or controls: the intercepted message can be left in its original state or modified; afterwards, the message can be sent to its original destination or discarded.For both VB 6 and VB.NET developers, Subclassing & Hooking with Visual Basic opens up a wealth of possibilities that ordinarily would be completely unavailable, or at least not easy to implement.
1100322956
Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

Subclassing & Hooking with Visual Basic offers developers a unique way to customize Windows behavior.Windows is a message-based system. Every action you request creates one or more messages to carry out the action. These messages are passed between objects and carry with them information that gives the recipient more detail on how to interpret and act upon the message.With Subclassing and the Windows hooking mechanism ("hooks"), you can manipulate, modify, or even discard messages bound for other objects within the operating system, in the process changing the way the system behaves. What kinds of results can you achieve using the power of subclassing and hooking? Here are just a few of the possibilities:

  • Determine when a window is being activated or deactivated and respond to this change.
  • Display descriptions of menu items as the mouse moves across them.
  • Disallow a user to move or resize a window.
  • Determine where the mouse cursor is and respond accordingly.
  • Determine when the display resolution has been changed.
  • Monitor the system for a low system resource condition.
  • Modify or disallow keystrokes sent to a window or a control.
  • Create an automated testing application.
  • Determine when an application is idle.
Along with this power comes responsibility; Windows is very unforgiving if subclassing and hooking are used incorrectly. Subclassing & Hooking with Visual Basic demonstrates the various techniques for intercepting messages bound for one or more windows or controls: the intercepted message can be left in its original state or modified; afterwards, the message can be sent to its original destination or discarded.For both VB 6 and VB.NET developers, Subclassing & Hooking with Visual Basic opens up a wealth of possibilities that ordinarily would be completely unavailable, or at least not easy to implement.
46.99 In Stock
Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

by Stephen Teilhet
Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

Subclassing and Hooking with Visual Basic: Harnessing the Full Power of VB/VB.NET

by Stephen Teilhet

eBook

$46.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Subclassing & Hooking with Visual Basic offers developers a unique way to customize Windows behavior.Windows is a message-based system. Every action you request creates one or more messages to carry out the action. These messages are passed between objects and carry with them information that gives the recipient more detail on how to interpret and act upon the message.With Subclassing and the Windows hooking mechanism ("hooks"), you can manipulate, modify, or even discard messages bound for other objects within the operating system, in the process changing the way the system behaves. What kinds of results can you achieve using the power of subclassing and hooking? Here are just a few of the possibilities:

  • Determine when a window is being activated or deactivated and respond to this change.
  • Display descriptions of menu items as the mouse moves across them.
  • Disallow a user to move or resize a window.
  • Determine where the mouse cursor is and respond accordingly.
  • Determine when the display resolution has been changed.
  • Monitor the system for a low system resource condition.
  • Modify or disallow keystrokes sent to a window or a control.
  • Create an automated testing application.
  • Determine when an application is idle.
Along with this power comes responsibility; Windows is very unforgiving if subclassing and hooking are used incorrectly. Subclassing & Hooking with Visual Basic demonstrates the various techniques for intercepting messages bound for one or more windows or controls: the intercepted message can be left in its original state or modified; afterwards, the message can be sent to its original destination or discarded.For both VB 6 and VB.NET developers, Subclassing & Hooking with Visual Basic opens up a wealth of possibilities that ordinarily would be completely unavailable, or at least not easy to implement.

Product Details

ISBN-13: 9781491932681
Publisher: O'Reilly Media, Incorporated
Publication date: 06/15/2001
Sold by: Barnes & Noble
Format: eBook
Pages: 706
File size: 3 MB

About the Author

Stephen Teilhet earned a degree in electrical engineering but soon afterwards began writing software for the Windows platform. For the last eight years, he has worked for several consulting firms on a wide range of projects, specializing in Visual Basic, Visual C++, MTS, COM, MSMQ, and SQL Server. Stephen currently works for Compuware Numega Labs in Nashua, New Hampshire, where he is immersed in the Microsoft .NET technologies.

Table of Contents

Prefacexi
I.Introducing Subclassing and Hooking1
1.Introduction3
Subclassing4
The Window Hooking Mechanism5
Tools to Aid Us in Our Efforts6
A Word of Warning16
2.Windows System-Specific Information17
Inside a Windows Application18
Inside the Windows Messaging System42
Performance Considerations47
3.The Basics of Subclassing and Hooks48
What Is Subclassing?48
What Are Hooks?67
II.Subclassing and Superclassing81
4.Subclassing83
The AddressOf Operator83
Some Subclassing Tips90
Instance Subclassing: An Example91
Global Subclassing112
Summary of Key Points in Subclassing131
5.Subclassing the Windows Common Dialog Boxes133
How Common Dialog Box Subclassing Works135
Using the Resource150
Creating the Subclassing Application154
Subclassing Common Dialog Boxes Other Than Open and Save As175
Problems Subclassing the Find and Replace Common Dialogs191
6.ActiveX Controls and Subclassing195
Subclassing a Third-Party ActiveX Control195
Subclassing an ActiveX Control Created in VB196
Subclassing a UserControl from Within a VB-Created ActiveX Control202
Creating an ActiveX Control That Subclasses Other Windows209
7.Superclassing218
What Is Superclassing?218
How the Superclassing Example Works223
Peering into the Superclassing Application with Spy++243
8.Debugging Techniques for Subclassing247
Where to Start247
Microsoft Tools252
NuMega's SmartCheck254
III.Hooking267
9.WH_CALLWNDPROC269
How WH_CALLWNDPROC Works269
A Thread-Specific Example279
Caveats285
10.WH_CALLWNDPROCRET286
How WH_CALLWNDPROCRET Works286
A Thread-Specific Example289
Caveats296
11.WH_GETMESSAGE298
How WH_GETMESSAGE Works298
A Thread-Specific Example304
Caveats312
12.WH_KEYBOARD and WH_KEYBOARD_LL314
How Keyboard Messaging Operates314
Description of Hooks318
A Thread-Specific Example324
A System-Wide Example330
A Low-Level Hook Example335
Caveats339
13.WH_MOUSE and WH_MOUSE_LL341
How Mouse Messaging Operates341
Description of Hooks345
Location of This Hook in the System351
A Single-Thread Example351
A System-Wide Hook Example355
Caveats365
14.WH_FOREGROUNDIDLE366
Description366
Location of This Hook in the System367
Background Processing Example369
Caveats374
15.WH_MSGFILTER376
Description376
A Thread-Specific Example384
Caveats389
16.WH_SYSMSGFILTER391
Description391
A System-Wide Example393
Caveats399
17.WH_SHELL400
Description400
Location of This Hook in the System408
A Thread-Specific Example409
Caveats416
18.WH_CBT418
Description420
A Thread-Specific Example429
Caveats443
19.WH_JOURNALRECORD444
Description444
The Macro Recorder Example450
Caveats457
20.WH_JOURNALPLAYBACK458
Description458
The Macro Recorder/Playback Example462
Caveats470
21.WH_DEBUG472
Description472
A Thread-Specific Example475
Some WH_DEBUG Scenarios485
Caveats487
IV.The .NET Platform489
22.Subclassing .NET WinForms491
What Is a WinForm?491
Instance Subclassing494
Subclassing a Control511
Superclassing514
Superclassing a Control519
Intercepting Keystrokes in a WinForm522
Behind the Scenes with Spy++529
23.Implementing Hooks in VB.NET534
Hooks and VB.NET534
Delegates535
Implementing the WH_KEYBOARD Hook540
Implementing the WH_MOUSE Hook547
V.Appendixes555
A.Messages557
B.API Functions601
C.Structures and Constants630
Index663
From the B&N Reads Blog

Customer Reviews