OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Using WinMain and OwlMain

ObjectWindows provides a default WinMain function that provides extensive error checking and exception handling.

This WinMain function sets up the application and calls the OwlMain function.

Although you can use your own WinMain by placing it in a source file, there is little reason to do so. Everything you would otherwise do in WinMain you can do in OwlMain or in TApplication initialization member functions. In the following example, OwlMain checks to see whether the use specified any parameters on the application's command line. If so, OwlMain creates the application object and uses the first parameter as the application name. If not, OwlMain creates the application object and uses Wow! as the application name.

#include <owl\applicat.h>
#include <string.h>
class TMyApplication: public TApplication
{
public:
TMyApplication(const char far* name = 0) : TApplication(name) {}
};
int
OwlMain(int argc, char* argv[])
{
char title[30];
if(argc >= 2)
else
strcpy(title, "Wow!");
return TMyApplication(title).Run();
}
Definition of class TApplication.
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
Definition of class TString, a flexible universal string envelope class.

If you do decide to provide your own WinMain, TApplication supports passing traditional WinMain function parameters with another constructor. The following example shows how to use that constructor to pass WinMain parameters to the TApplication object:

#include <owl\applicat.h>
class TMyApplication : public TApplication
{
public:
TMyApplication (const char far* name,
const char far* cmdLine,
int cmdShow)
: TApplication (name, instance, prevInstance, cmdLine, cmdShow){}
};
int
hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
return TMyApplication("MyApp", hInstance, hPrevInstance, lpszCmdLine, nCmdShow).Run();
}