OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Every ObjectComponents application needs a registrar object to manage all of its registration tasks.
In a linking and embedding application, the registrar is an object of type TOcRegistrar. Insert the following line after the #include statements in your main .CPP file.
The TPointer template ensures that the Registrar object is destructed when the program ends.
static
, and the pointer type should be TPointer<TRegistrar>
, not TPointer<TOcRegistrar>
. However, note that Registrar must still point to a TOcRegistrar object.The next step is to modify your OwlMain function to allocate a new TOcRegistrar object and initialize the global pointer Registrar. The TOcRegistrar constructor expects three parameters: the application's registration structure, the component's factory callback and the command-line string that invoked that application. The registration structure is created with the registration macros.
The factory callback is created with a class template. For a linking and embedding ObjectWindows application that uses Doc/View, the template is called TOleDocViewFactory. The third parameter, the command-line string, can be obtained from the GetCmdLine method of TApplication. The code in the factory template assumes you have defined an application dictionary called AppDictionary and a pointer to TRegistrar called Registrar.
After initializing the Registrar pointer, your OLE container application must invoke the Run method of the registrar instead of TApplication::Run. TRegistrar::Run calls the factory callback procedure (the one the second parameter points to) and causes the application to create itself. The application enters its message loop, which is actually in the factory callback. The following code shows an example of OwlMain after adding a registrar object.
The last parameter of the TOcRegistrar constructor is the command line string that invoked the application.