OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Step 3: Deriving the application object from TOcModule

ObjectWindows provides the mix-in class TOcModule for applications that support linking and embedding.

Change your application object so it derives from both TApplication and TOcModule as shown in the following example:

// Non-OLE application
class TScribbleApp : public TApplication { /* declarations */ };
// New declaration of same class
class TScribbleApp : public TApplication, public TOcModule { /* declarations */ };

The TOcModule object coordinates basic housekeeping chores related to registration and memory management. It also connects your application object to OLE.

Your TApplication-derived class must provide a CreateOleObject method with the following signature:

TUnknown* CreateOleObject(uint32 options, TDocTemplate* tpl);

The method is used by the factory template class. Because containers don't create OLE objects, a container can implement CreateOleObject by simply returning 0. Servers have more work to do to implement CreateOleObject.

//
// non-OLE application class
//
class TScribbleApp : public TApplication
{
public:
TApplication("Scribble Pad") {}
protected:
InitMainWindow();
};
//
// New declaration of same class
//
class TScribbleApp : public TApplication,
public TOcModule {
public:
TScribbleApp() : TApplication(::AppReg["description"]){}
TUnknown* CreateOleObject(uint32, TDocTemplate*){ return 0; }
protected:
InitMainWindow();