
■ OwlMain is discussed in Chapter 3.
■ TFrameWindow is discussed in Chapter 6.
Step 2: Handling Windows events
Y u can find theo
Step 2 introduces response tables, another very important ObjectWindows
source for Step 2 in
feature. Response tables control event and message processing in
the file STEP02.CPP
ObjectWindows 2.0 applications, dispatching events on to the proper
in the directory
EXAMPLES\OWL\
event-handling functions. Step 2 also adds these functions.
TUTORIAL.
Add the response table to the application using a window class called
Adding a window
TMyWindow. TMyWindow is derived from TWindow, and looks like this:
class
class TMyWindow : public TWindow
{
public:
TMyWindow(TWindow* parent = 0);
protected:
// override member function of TWindow
BOOL CanClose();
// message response functions
void EvLButtonDown(UINT, TPoint&);
void EvRButtonDown(UINT, TPoint&);
DECLARE_RESPONSE_TABLE(TMyWindow);
};
The constructor for this class is fairly simple. It takes a single parameter a,
TWindow * that indicates the parent window of the object. The constructor
definition looks like this:
TMyWindow::TMyWindow(TWindow *parent)
{
Init(parent, 0, 0);
}
The Init function lets you initialize TMyWindow’ base class. In this case, thes
call isn’t very complicated. The only thing that might be required for your
purposes is the window’ parent, and, as you’ll see, even that’ taken care ofs s
for you.
The only public member of the TMyWindow class is its constructor But if.
Adding a
the other members are protected, how can you access them? The answer
response table
lies in the response table definition. Notice the last line of the TMyWindow
30
OWL P ogrammer’ Guider s