Book description
Subclassing & Hooking with Visual Basic offersdevelopers a unique way to customize Windows behavior. Windows is amessage-based system. Every action you request creates one or moremessages to carry out the action. These messages are passed betweenobjects and carry with them information that gives the recipientmore detail on how to interpret and act upon the message. WithSubclassing and the Windows hooking mechanism ("hooks"), you canmanipulate, modify, or even discard messages bound for otherobjects within the operating system, in the process changing theway the system behaves. What kinds of results can you achieve usingthe power of subclassing and hooking? Here are just a few of thepossibilities:
Determine when a window is being activated ordeactivated and respond to this change.
Display descriptions of menu items as the mousemoves across them.
Disallow a user to move or resize a window.
Determine where the mouse cursor is and respondaccordingly.
Determine when the display resolution has beenchanged.
Monitor the system for a low system resourcecondition.
Modify or disallow keystrokes sent to a window or acontrol.
Create an automated testing application.
Determine when an application is idle.
Along with this power comes responsibility; Windows is veryunforgiving if subclassing and hooking are used incorrectly.Subclassing & Hooking with Visual Basic demonstrates thevarious techniques for intercepting messages bound for one or morewindows or controls: the intercepted message can be left in itsoriginal state or modified; afterwards, the message can be sent toits original destination or discarded. For both VB 6 and VB.NETdevelopers, Subclassing & Hooking with Visual Basicopens up a wealth of possibilities that ordinarily would becompletely unavailable, or at least not easy to implement.
Table of contents
- Subclassing and Hooking with Visual Basic
- A Note Regarding Supplemental Files
- Preface
- I. Introducing Subclassing and Hooking
-
II. Subclassing and Superclassing
- 4. Subclassing
-
5. Subclassing the Windows Common Dialog Boxes
- How Common Dialog BoxSubclassing Works
- Using the Resource
- Creating the Subclassing Application
- Subclassing Common Dialog Boxes Other Than Open and Save As
- Problems Subclassing the Find and Replace Common Dialogs
- 6. ActiveX Controls and Subclassing
- 7. Superclassing
- 8. Debugging Techniques for Subclassing
- III. Hooking
- IV. The .NET Platform
-
V. Appendixes
-
A. Messages
-
Window Messages
- Public Const WM_NULL = &H0
- Public Const WM_CREATE = &H1
- Public Const WM_DESTROY = &H2
- Public Const WM_MOVE = &H3
- Public Const WM_SIZE = &H5
- Public Const WM_ACTIVATE = &H6
- Public Const WM_SETFOCUS = &H7
- Public Const WM_KILLFOCUS = &H8
- Public Const WM_SETTEXT = &HC
- Public Const WM_PAINT = &HF
- Public Const WM_QUIT = &H12
- Public Const WM_ERASEBKGND = &H14
- Public Const WM_SHOWWINDOW = &H18
- Public Const WM_SETCURSOR = &H20
- Public Const WM_QUEUESYNC = &H23
- Public Const WM_GETMINMAXINFO = &H24
- Public Const WM_WINDOWPOSCHANGING = &H46
- Public Const WM_WINDOWPOSCHANGED = &H47
- Public Const WM_CANCELJOURNAL = &H4B
- Public Const WM_NCCREATE = &H81
- Public Const WM_NCDESTROY = &H82
- Public Const WM_NCCALCSIZE = &H83
- Public Const WM_NCHITTEST = &H84
- Public Const WM_NCPAINT = &H85
- Public Const WM_NCACTIVATE = &H86
- Public Const WM_GETDLGCODE = &H87
- Public Const WM_NCMOUSEMOVE = &HA0
- Public Const WM_NCLBUTTONDOWN = &HA1
- Public Const WM_NCLBUTTONUP = &HA2
- Public Const WM_NCLBUTTONDBLCLK = &HA3
- Public Const WM_NCRBUTTONDOWN = &HA4
- Public Const WM_NCRBUTTONUP = &HA5
- Public Const WM_NCRBUTTONDBLCLK = &HA6
- Public Const WM_NCMBUTTONDOWN = &HA7
- Public Const WM_NCMBUTTONUP = &HA8
- Public Const WM_NCMBUTTONDBLCLK = &HA9
- Public Const WM_NCXBUTTONDOWN = &HAB
- Public Const WM_NCXBUTTONUP = &HAC
- Public Const WM_NCXBUTTONDBLCLK = &HAD
- Public Const WM_KEYDOWN = &H100
- Public Const WM_KEYUP = &H101
- Public Const WM_CHAR = &H102
- Public Const WM_SYSKEYDOWN = &H104
- Public Const WM_SYSKEYUP = &H105
- Public Const WM_SYSCHAR = &H106
- Public Const WM_INITDIALOG = &H110
- Public Const WM_COMMAND = &H111
- Public Const WM_SYSCOMMAND = &H112
- Public Const WM_ENTERIDLE = &H121
- Public Const WM_CTLCOLOREDIT = &H133
- Public Const WM_CTLCOLORLISTBOX = &H134
- Public Const WM_CTLCOLORBTN = &H135
- Public Const WM_CTLCOLORDLG = &H136
- Public Const WM_CTLCOLORSCROLLBAR = &H137
- Public Const WM_CTLCOLORSTATIC = &H138
- Public Const WM_MOUSEMOVE = &H200
- Public Const WM_LBUTTONDOWN = &H201
- Public Const WM_LBUTTONUP = &H202
- Public Const WM_LBUTTONDBLCLK = &H203
- Public Const WM_RBUTTONDOWN = &H204
- Public Const WM_RBUTTONUP = &H205
- Public Const WM_RBUTTONDBLCLK = &H206
- Public Const WM_MBUTTONDOWN = &H207
- Public Const WM_MBUTTONUP = &H208
- Public Const WM_MBUTTONDBLCLK = &H209
- Public Const WM_XBUTTONDOWN = &H20B
- Public Const WM_XBUTTONUP = &H20C
- Public Const WM_XBUTTONDBLCLK = &H20D
- Public Const WM_PARENTNOTIFY = &H210
- Public Const WM_ENTERMENULOOP = &H211
- Public Const WM_EXITMENULOOP = &H212
- Public Const WM_SIZING = &H214
- Public Const WM_CAPTURECHANGED = &H215
- Public Const WM_MOVING = &H216
- Public Const WM_ENTERSIZEMOVE = &H231
- Public Const WM_EXITSIZEMOVE = &H232
- Public Const WM_HOTKEY = &H312
- Button Control-Specific Messages
- Combo Box-Specific Messages
- Edit Control-Specific Messages
- Listbox-Specific Messages
- Scroll Bar-Specific Messages
- Messages Specific to the CommonDialog Boxes
- Messages Specific to the Font Common Dialog Box
- Messages Specific to the Page Setup Common Dialog Box
-
Window Messages
-
B. API Functions
- AttachThreadInput
- BroadcastSystemMessage
- CallNextHookEx
- CallWindowProc
- ChooseColor
- ChooseFont
- CopyMemory
- CreateWindowEx
- DefWindowProc
- EnumChildWindows
- FindText
- FindWindow
- FindWindowEx
- GetClassInfoEx
- GetDeskTopWindow
- GetDlgItem
- GetMessage
- GetParent
- GetSaveFileName
- GetWindow
- GetWindowLong
- GetWindowRect
- OutputDebugStringA
- PageSetupDlg
- PeekMessage
- PostMessage
- PostQuitMessage
- PostThreadMessage
- PrintDlg
- PrintDlgEx
- RegisterClassEx
- RegisterWindowMessage
- ReleaseCapture
- ReplaceText
- SendDlgItemMessage
- SendMessage
- SendMessageCallback
- SendMessageTimeout
- SendNotifyMessage
- SetCapture
- SetClassLongPtr
- SetWindowLongPtr
- SetWindowPos
- SetWindowsHookEx
- ShowWindow
- UnhookWindowsHookEx
- UnregisterClass
-
C. Structures and Constants
- CBT_CREATEWND
- CBTACTIVATESTRUCT
- CHOOSECOLOR
- CHOOSEFONT
- CWPRETSTRUCT
- CWPSTRUCT
- DEBUGHOOKINFO
- EVENTMSG
- FINDREPLACE
- KBDLLHOOKSTRUCT
- MOUSEHOOKSTRUCT
- MOUSEHOOKSTRUCTEX
- MSG
- MSLLHOOKSTRUCT
- NMHDR
- OPENFILENAME
- PAGESETUPDLG
- POINTAPI
- PRINTDLG
- PRINTDLGEX
- RECT
- WNDCLASSEX
- Message (.NET Structure)
-
Constants
- BroadcastSystemMessage Function Masks
- Common Dialog Box Error Messages
- Common Dialog Box Notification Messages
- Class Styles
- Edit Control Notification Codes
- Extended Window Styles
- GetClassLongPtr Function Constants
- GetWindow API Function Constants
- GetWindowLongPtr Function Constants
- Hook Codes
- HSHELL_ACCESSIBILITYSTATE Constants
- Key State Masks for Mouse Messages
- Low-Level Hook Constants
- Mouse Wheel Constant
- Open and Save As Common Dialog BoxNotification Codes
- PeekMessage Function Options
- PostMessage and SendMessage Function Constants
- Predefined Control ID Values for the Open andSave As Common Dialog Boxes
- SendMessageTimeout API Function Constants
- SetWindowLongPtr/GetWindowLongPtr Function Constants
- SetWindowPos Function Constants
- ShowWindow Function Constants
- User Button Notification Codes
- Virtual Key Codes
- Window Hook Constants
- Window Styles
- WM_KEYUP, WM_DOWN, andWM_CHAR lParam HIWORD Flags
- WM_NCHITTEST Codes
- WH_SHELL Codes for the HSHELL_APPCOMMAND Hook Code
- WM_SIZE Message wParam Values
- WM_SYSCOMMAND Message wParam Constants
- XButton Constants
-
A. Messages
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Subclassing and Hooking with Visual Basic
- Author(s):
- Release date: June 2001
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596001186
You might also like
book
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …
audiobook
Algorithms
Digital technology runs on algorithms, sets of instructions that describe how to do something efficiently. Application …
book
CSS Master, 3rd Edition
CSS has grown from a language for formatting documents into a robust languagefor designing web applications. …
audiobook
Fall in Love with the Problem, Not the Solution
Unicorns-companies that reach a valuation of more than $1 billion-are rare. Uri Levine has built two. …