A SERVICE OF

logo

The event-handling functions for these macros are VnAppend,
VnDelete, and VnModify. All three of these functions return a BOOL
and take a single parameter an int indicating which line in the,
document is affected by the event.
The VnAppend function gets notification that a line was appended to
the document. It then draws the new line in the view’ window. Its
should create a device context, get the line from the document, call
the line’ Draw function with the device context object as thes
parameter then return TRUE. The code for this function looks like,
this:
BOOL TDrawView::VnAppend(unsigned int index)
{
TClientDC dc(*this);
const TLine* line = DrawDoc->GetLine(index);
line->Draw(dc);
return TRUE;
}
The VnModify function forces a repaint of the entire window. It might
seem more efficient to just redraw the affected line, but you would
need to paint over the old line, repaint the new line, and restore any
lines that might have crossed or overlapped the affected line. It is
actually more efficient to invalidate and repaint the entire window. So
the code for the VnModify function should look like this:
BOOL TDrawView::VnModify(unsigned int /*index*/)
{
Invalidate(); // force full repaint
return TRUE;
}
The VnDelete function also forces a repaint of the entire window. This
function faces the same problem as VnModify; simply erasing the line
will probably affect other lines. The code for the VnDelete function
should look like this:
BOOL TDrawView::VnDelete(unsigned int /*index*/)
{
Invalidate(); // force full repaint
return TRUE;
}
The purpose of the TDrawListView class is to display the data
TDrawListView
contained in a TDrawDocument object as a list of lines. Each line will
display the color values for the line, the pen size for the line, and the
number of points that make up the line. TDrawListView will let the
Chapter 2, Learning ObjectWindows
109