Cover | Table of Contents | Colophon
WH_CALLWNDPROC
WH_CALLWNDPROCRET
WH_CBT
WH_DEBUG
WH_FOREGROUNDIDLE
WH_GETMESSAGE
WH_JOURNALPLAYBACK
WH_JOURNALRECORD
WH_KEYBOARD
WH_KEYBOARD_LL
WH_MOUSE
WH_MOUSE_LL
WH_MSGFILTER
WH_SYSMSGFILTER
WH_SHELL
WH_SHELL hook. For example,
the WH_SHELL hook only provides information on
top-level, unowned windows.
MSG structure, defined as
follows:
A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure.
A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure, as well as after they are processed by the target window procedure.
AddressOf
operator. A fair amount of discussion is given to this operator
because it plays a pivotal role in using Visual Basic (VB) to
subclass windows. Presented next will be the two types of
subclassing -- instance and global subclassing. Their
similarities, differences, and applications are discussed at length.
Code examples will be presented for both types of subclassing. These
examples are meant to be for illustration only; such things as error
handling code will be omitted for clarity.
AddressOf operator, first introduced in Version 5 of VB, gave developers
limited access to pointers, a feature that VB effectively hides from
them but that is essential to high-end development environments such
as Visual C++. The AddressOf operator greatly
increases the potential of a VB application. As we shall see, though,
there are always bumps in the road when implementing more advanced
functionality, and AddressOf has several of them.
AddressOf provides the VB developer with a simple
way of using function pointers without relying on another language. A
function pointer is simply
a variable that contains the memory
location of a single function. In other words, this variable points
to a function. Now, instead of having to use the function name to
call the function, we can instead use the function pointer to call
the function.
AddressOf operator, first introduced in Version 5 of VB, gave developers
limited access to pointers, a feature that VB effectively hides from
them but that is essential to high-end development environments such
as Visual C++. The AddressOf operator greatly
increases the potential of a VB application. As we shall see, though,
there are always bumps in the road when implementing more advanced
functionality, and AddressOf has several of them.
AddressOf provides the VB developer with a simple
way of using function pointers without relying on another language. A
function pointer is simply
a variable that contains the memory
location of a single function. In other words, this variable points
to a function. Now, instead of having to use the function name to
call the function, we can instead use the function pointer to call
the function.
AddressOf must be used
greatly limit its functionality and make it far less powerful than
many VB developers had originally hoped. It seems that
Microsoft's plans for introducing VB developers to function
pointers was primarily meant to allow access to Windows API functions
that were previously unusable. Great, but what about using function
pointers within a pure VB application? By this I mean calling a VB
function and passing it a function pointer using
On
Error
Resume
Next for error handling
in the callback function) apply as well to subclassed window
procedures. In addition, though, two tips and pitfalls that are
unique to subclassing are worth mentioning.
|
Object
|
Property Name
|
Property Value
|
|---|---|---|
|
frmCh4
|
Caption
|
"Chapter 4 -- Subclassing Example"
|
|
frmCh4
|
ClientHeight
|
3612
|
|
frmCh4
|
ClientLeft
|
48
|
|
frmCh4
|
ClientTop
|
336
|
|
frmCh4
|
ClientWidth
|
WM_CREATE
and WM_NCCREATE. When a
window
is created, the WM_NCCREATE message is sent first
to the window to finish creating its nonclient area in memory. The
WM_CREATE message is sent next to finish creating
the window's client area in memory. Note that the window is
still not displayed on the screen at this point. Other messages still
need to be sent to the window to position, size, and paint it on the
desktop.
On
Error
Resume
Next for error handling
in the subclassed window procedure.
End statement in your code or the
Stop button in the VB IDE.
LoadResData(resID, resType)
|
Control Name
|
Property Name
|
Property Value
|
|---|---|---|
|
frmMain
|
Caption
|
Ch5 - Common Dialog Subclassing Example
|
|
frmMain
|
BorderStyle
|
3-Fixed Dialog
|
|
frmMain
|
Top
|
0
|
|
frmMain
|
Left
|
0
|
|
frmMain
|
Height
|
3420
|
|
frmMain
|
Width
|
5760 |
|
Dialog type
|
Resource ID
|
Resource File
|
Header File
|
|---|---|---|---|
|
Color |
TRUE value, it has processed the message and the
TranslateMessage and the
DispatchMessage API functions should not be
called. The IsDialogMessage API function's
main purpose is to provide default dialog keyboard processing for the
modeless dialog box. Modal dialog boxes automatically support default
dialog keyboard processing. Here is the list of
default dialog keyboard keys processed by
the IsDialogMessage API function: