OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Every ObjectComponents application needs to create a registrar object to manage all of its registration tasks.
Insert the following line after the #include statements in your main .CPP file.
The Registrar object is created in your OwlMain function. 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 to initialize the global pointer Registrar. The TOcRegistrar constructor requires three parameters: the application's registration structure, the component's factory callback and the command line string that invoked that application.
You can write your own callback function from scratch if you prefer, but the templates are much easier to use. For a linking and embedding ObjectWindows application that doesn't use Doc/View, the template class is called TOleFactory. The code in the factory template assumes you have defined an application dictionary called AppDictionary and a pointer to TRegistrar called Registrar.
Factories are explained in more detail in the ObjectWindows Reference Guide. After initializing the Registrar pointer, your OLE container application must invoke TOcRegistrar::Run instead of TApplication::Run. For OLE containers, the registrar's Run simply invokes the application object's Run to create the application's windows and process messages. In a server, however, TOcRegistrar::Run does more. Using the registrar's Run method in a container makes it easier to modify the application later if you decide to turn it into a server.
Here is an example of OwlMain after adding the registrar object: