OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Step 4: Inheriting from OLE classes

A server makes the same changes to its OLE classes that a container makes.

ObjectWindows wraps a great deal of power in its new window, document, and view classes. To give an ObjectWindows program OLE capabilities, change its derived classes to inherit from OLE classes. Here are some examples:

// old declarations (without OLE)
class TMyDocument: public TDocument { /* declarations */ };
class TMyView: public TView { /*
* declarations */ };
class TMyFrame: public TFrameWindow<FONT FACE="Courier New"
{ /* declarations */ );
// new declarations (with OLE)
class TMyDocument: public TOleDocument { /* declarations */ };
class TMyView: public TOleView { /* declarations */ };
class TMyFrame: public TOleFrame { /* declarations */ );

When you change to OLE classes, be sure that those methods in your classes which refer to their direct base classes now use the OLE class names.

void TMyView::Paint(TDC& dc, BOOL erase, TRect& rect)
{
TOleView::Paint(dc, erase, rect);
// paint the view here
}

It is generally safer to allow the OLE classes to handle Windows events and Doc/View notifications. This is particularly true for the Paint method and mouse message handlers in classes derived from TOleView. TOleView::Paint knows how to paint the objects embedded in your document. (Servers are often containers as well, and a server's object might have other objects embedded in it.) Similarly, the mouse handlers of TOleView let the user select, move, resize, and activate an OLE object embedded or linked in your document.