OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Step 8: Telling clients when an object changes

Whenever the server makes any changes that alter the appearance of an object, the server must tell OLE.

OLE keeps a metafile representation with every linked or embedded object so that even when the server is not active OLE can still draw the object for the container. If the object changes, OLE must update the metafile. The server notifies OLE of the change by calling TOleView::InvalidatePart. OLE, in turn, asks the server to paint the revised object into a new metafile. ObjectComponents handles this request by passing the metafile device context to the server's Paint procedure. You don't need to write extra code for updating the metafile.

A good place to call InvalidatePart is in the handlers for the messages that ObjectWindows sends to a view when its data changes:

bool TDrawView::VnRevert(bool /*clear*/)
{
Invalidate(); // force full repaint
InvalidatePart(invView); // tell container about the change
return true;
}

invView is an enumeration value, defined by ObjectComponents, indicating that the view is invalid and needs repainting.

Other view notification messages that signal the need for an update include EV_VN_APPEND, EV_VN_MODIFY, and EV_VN_DELETE.