OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing the application object

When you construct a TApplication object, it calls its TApplication::InitApplication(), TApplication::InitInstance(), and TApplication::InitMainWindow() member functions to start the application.

You can override any of those members to customize how your application initializes. You must override InitMainWindow to have a useful application. To override a function in TApplication you need to derive your own application class from TApplication.

The constructor for the TApplication-derived class TMyApplication, shown in the examples that follow, takes the application name as its only argument; its default value is zero, for no name. The application name is used for the default main window title and in error messages. The application name is referenced by a char far* member of the TModule base class called Name. You can set the application name one of two ways:

  • Your application class constructor can explicitly call TApplication's constructor, passing the application name onto TApplication. The following example shows this method:
    #include <owl\applicat.h>
    class TMyApplication: public TApplication
    {
    public:
    // This constructor initializes the base class constructor
    TMyApplication(const char far* name = 0) : TApplication(name) {}
    .
    .
    .
    };
    Definition of class TApplication.
  • Override one of TApplication's initialization functions, usually InitMainWindow, and set the application name there. The following example shows this method:
    #include <owl\applicat.h>
    class TMyApplication: public TApplication
    {
    public:
    // This constructor just uses the default base class constructor.
    TMyApplication(const char far* name = 0) : Name(name) {}
    void InitMainWindow()
    {
    .
    .
    .
    protected:
    string Name;
    };
    ObjectWindows applications do not require an explicit WinMain function; the ObjectWindows libraries provide one that performs error handling and exception handling. You can perform any initialization you want in the OwlMain function, which is called by the default WinMain function.

To construct an application object, create an instance of your application class in the OwlMain function. The following example shows a simple application object's definition and instantiation:

#include <owl\applicat.h>
class TMyApplication: public TApplication
{
public:
TMyApplication(const char far* name = 0): TApplication(name) {}
};
int OwlMain(int argc, char* argv[])
{
return
TMyApplication("Wow!").Run();
}
STDAPI_(owl::TDocTemplate **) GetDocTemplateHead(owl STDAPI_(owl::TModule **) GetModulePtr(owl in OwlMain)(int argc, TCHAR *argv[])
Main entry point for an Owl application.
Definition module.h:391