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

ObjectComponents requires that the class you derive from TApplication must also inherit from TOcModule.

In addition, the application object needs to implement a CreateOleObject method with the following signature:

TUnknown* CreateOleObject(uint32 options, TRegList* link);

The purpose of the function is to create a server document for linking or embedding. The server must create a client window and return a pointer of type TOcRemView*. Here is how OWLOCF2 declares this procedure:

class TScribbleApp : public TApplication,
public TOcModule {
public:
TUnknown* CreateOleObject(uint32 options, TRegLink* link);

and here is how it implements the procedure:

TUnknown*
TScribbleApp::CreateOleObject(uint32 options, TRegLink* link)
{
if (!link) // factory creating an application only, no view required
link = &scribbleLink; // need to have a view for this app
TOleFrame* olefr = TYPESAFE_DOWNCAST(GetMainWindow(), TOleFrame);
FileData.FileName[0] = 0;
olefr->GetRemViewBucket(), FileData, link);
client->Create();
return client->GetOcRemView();
}
#define CHECK(condition)
Definition checks.h:239
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269

ObjectWindows uses the CreateOleObject method to inform your application when OLE needs the server to create an object. The TRegLink* parameter indicates which object to create.