class definition. This declares the response table; that is, it informs your
class that it has a response table, much like a function declaration informs
the class that the function exists, but doesn’t define the function’ activitys .
The response table definition sets up your class to handle Windows events
and to pass each event on to the proper event-handling function. As a
general rule, event-handling functions should be protected; this prevents
classes and functions outside your own class from calling them. Here is the
response table definition for TMyWindow:
DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
END_RESPONSE_TABLE;
Y u can put the response table anywhere in your source file.o
For now you can keep the response table fairly simple. Here’ a description, s
of each part of the table. A response table has four important parts:
■ The response table declaration in the class declaration.
■ The first line of a response table definition is always the
DEFINE_RESPONSE_T BLEX macro. The value of X depends on yourA
class’ inheritance, and is based on the number of immediate base classes
your class has. In this case, TMyWindow has only one immediate base
class, TWindow.
■ The last line of a response table definition is always the
END_RESPONSE_T BLE macro, which ends the event response tableA
definition.
■ Between the DEFINE_RESPONSE_T BLEX macro and theA
END_RESPONSE_T BLE macro are other macros that associateA
particular events with their handling functions.
The two macros in the middle of the response table,
EV_WM_LBUTTONDOWN and EV_WM_RBUTTONDOWN, are response
table macros for the standard Windows messages WM_LBUTTONDOWN
and WM_RBUTTONDOWN. All standard Windows messages have
ObjectWindows-defined response table macros. T find the name of ao
particular message’ macro, preface the message name with EV_. Fors
example, the macro that handles the WM_PAINT message is
EV_WM_PAINT and the macro that handles the WM_LBUTTONDOWN,
message is EV_WM_LBUTTONDOWN.
These predefined macros pass the message on to functions with predefined
names. T determine the function name, substitute Ev for WM_, ando
convert the name to lowercase with capital letters at word boundaries. For
example, the WM_PAINT message is passed to a function called EvPaint,
Chapter 2, Learning ObjectWindows
31