OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Every ObjectComponents application needs a registrar object to manage 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.
After initializing the Registrar pointer, your OLE container application must invoke the Run method of the registrar 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. However, using the registrar method makes your application OLE server-ready. The following code shows an example of OwlMain after the addition of a registrar object.
The last parameter of the TOcRegistrar constructor is the command line string that invokes the application. The registrar object processes the command line by searching for switches, such as /Embedding or /Automation, that OLE may have placed there. ObjectComponents takes whatever action the switches call for and then removes them. If for some reason you need to test the OLE switches, be sure to do it before constructing the registrar. If you have no use for the OLE switches, wait until after constructing the registrar before parsing the command line.