A SERVICE OF

logo

Response tables are discussed in Chapter 5.
Main windows are discussed in Chapter 3.
P edefined response table macros and their corresponding event-r
handling functions are listed in Chapter 2 in the ObjectWindows Reference
Guide.
Step 3: Writing in the window
In Step 3, you’ll begin working with the new window that was added to the
application in Step 2. Instead of popping up a message box when the
mouse buttons are pressed, the event-handling functions will get some real
functionality—pressing the left mouse button will cause the coordinates of
the point at which the button was clicked to be printed in the window and,
pressing the right mouse button will cause the window to be cleared.
Y u can find theo
The code for this new functionality is in the EvLButtonDown function. The
source for Step 3 in
the file STEP03.CPP
TP int parameter that’ passed to the EvLButtonDown contains theo s
in the directory
coordinates at which the mouse button was clicked. Y u’ll need to add ao
EXAMPLES\OWL\
char string to the function to hold the text representation of the point. Y uo
TUTORIAL.
can then use the wsprintf function to format the string. Now you have to set
up the window to print the string.
T perform any sort of graphical operation in Windows, you must have ao
Constructing a
device context for the window or area you want to work with. The same
device context
holds true in ObjectWindows. ObjectWindows provides a number of
classes that make it easy to set up, use, and dispose of a device context.
Because TMyWindow works as a client in a frame window you’ll use the,
TClientDC class. TClientDC is a device context class that provides access to
the client area owned by a window. Like all ObjectWindows device context
classes, TClientDC is based on the TDC class, and is defined in the owl\dc.h
header file.
TClientDC has a single constructor that takes an HWND as its only
parameter Because you want a device context for your TMyWindow object,.
you need the handle for that window. As it happens, the TWindow base
class provides an HWND conversion operator This operator is called.
implicitly whenever you use the window object in places that require an
HWND. So the constructor for your TClientDC object looks something like
this:
TClientDC dc(*this);
Chapter 2, Learning ObjectWindows
35