A SERVICE OF

logo

Responding to general messages
Y u can also respond to messages that aren’t command messages, childo
ID-based messages, or notification messages.
ObjectWindows 1.0 and 2.0 dispatch Windows messages to specific
member functions. Notice that the ObjectWindows 2.0 naming convention
for Windows messages is to use the prefix Ev with a mixed-case version of
the Windows message constant:
// ObjectWindows 1.0 member function declaration
virtual void WMCtlColor(TMessage &Msg) = [WM_FIRST + WM_CTLCOLOR]
// ObjectWindows 2.0 event response table entry
EV_MESSAGE(WM_CTLCOLOR, EvCtlColor)
As with child ID-based messages, ObjectWindows defines macros to make
it easy to respond to Windows messages. Here’ an example that uses thes
predefined macro for the WM_CTLCOLOR message:
// ObjectWindows 2.0 event response table entry
EV_WM_CTLCOLOR
See Chapter 5 for
Using the predefined macros assumes you name your event response
more details about
function using the Ev naming convention.
the predefined
message macros.
Another good reason to use the predefined macros is that ObjectWindows
automatically “cracks” the parameters that are normally passed in the
LPARAM and WPARAM parameters.
For example, using EV_WM_CTLCOLOR assumes that you have an event
response member function declared like this:
HBRUSH EvCtlColor(HDC hDCChild, HWND hWndChild, UINT nCtrlType);
Message cracking provides for strict C++ compile-time type checking,
which helps you catch errors as you compile your code rather than at run
time.
Appendix A, Converting ObjectWindows 1.0 code to ObjectWindows 2.0
367