OWLNext 7.0
Borland's Object Windows Library for the modern age
|
ObjectWindows provides predefined macros for all standard Windows messages.
You can use these macros to handle standard Windows messages in one of your class's member functions.
To determine the name of the macro, preface the message name with EV_. For example, the macro that handles the WM_PAINT message is EV_WM_PAINT. The macro that handles the WM_LBUTTONDOWN message is EV_WM_LBUTTONDOWN.
These predefined macros pass the message on to functions with predefined names. To determine the function name, remove the WM_ from the message name, add Ev to the remaining part of the message name and convert the name to lowercase with capital letters at word boundaries. For example, the WM_PAINT message is passed to a function called EvPaint. The WM_LBUTTONDOWN message is passed to a function called EvLButtonDown.
The advantage of using these Windows message macros is that the Windows message is automatically cracked; that is, the parameters that are normally encoded in the LPARAM and WPARAM parameters are broken out into their constituent parts and passed to the event-handling function as individual parameters.
For example, the EV_WM_CTLCOLOR macro passes the cracked parameters to an event-handling function with the following signature:
Message cracking provides for strict C++ compile-time type checking and helps you catch errors as you compile your code rather when you run your code. It also helps when migrating applications from 16-bit to 32-bit and vice versa. See Standard Windows Messages for lists showing each Windows message response table macro and the signature of the corresponding event-handling function.
To use a predefined Windows message macro, add the macro to your response table and add the appropriate member function with the correct name and signature to your class, then define the member function to handle the message the way you want it to.
Suppose you want to perform some operation when your TMyFrame window object receives the WM_ERASEBKGND message. The code would look like this: