
void TMyWindow::EvRButtonDown(UINT, TPoint&)
{
Invalidate();
}
Here’ a guide to where you can find more information on the topicss
Where to find
introduced in this step:
more information
■ Device contexts and the TDC classes are discussed in Chapter 13.
■ Window classes are discussed in Chapter 6.
Step 4: Drawing in the window
Y u can find theo
In this step, you’ll add the ability to draw a line in the window by pressing
source for Step 4 in
the left mouse button and dragging. T do this, you’ll add a two newo
the file STEP04.CPP
events, WM_MOUSEMOVE and WM_LBUTTONUP, to the TMyWindow
in the directory
EXAMPLES\OWL\
response table, along with functions to handle those events. Y u’ll also addo
TUTORIAL.
a TClientDC * to the class.
T let the user draw on the window the application must handle a numbero ,
Adding new
of events:
events
■ T start drawing the line, you have to look for the user to press the lefto
mouse button. This is already taken care of by handling the
WM_LBUTTONDOWN event.
■ Once the user has pressed the left button down, you have to look for
them to move the mouse. At this point, you’re drawing the line. T knowo
when the user is moving the mouse, catch the WM_MOUSEMOVE event.
■ Y u then need to know when the user is finished drawing the line. Theo
user is finished when the left mouse button is released. Y u can monitoro
for this by catching the WM_LBUTTONUP event.
Y u need to add two macros to the window class’ response table,o
EV_WM_MOUSEMOVE and EV_WM_LBUTTONUP. The new response
table should look something like this:
DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
EV_WM_MOUSEMOVE,
EV_WM_LBUTTONUP,
END_RESPONSE_TABLE;
Chapter 2, Learning ObjectWindows
37