A SERVICE OF

logo

void
TMyWindow::Error()
{
// display message box containing the application name
MessageBox("An error occurred!",
GetApplication()->Name, MB_OK);
}
Here’ the smallest ObjectWindows application you can create:s
Creating the
#include <owl\applicat.h>
minimum
application
int
OwlMain(int argc, char* argv[])
{
return TApplication("Wow!").Run();
}
This creates a Windows application with a main window with the caption
“W w!” Y u can resize, move, minimize, maximize, and close this window.o o
In a real application, you’d derive a new class for the application to add
more functionality.
Initializing applications
Initializing an ObjectWindows application takes four steps:
Constructing the application object
Initializing the application
Initializing each new instance
Initializing the main window
When you construct a T pplication object, it calls its InitApplication,A
Constructing the
InitInstance, and InitMainWindow member functions to start the application.
application object
Y u can override any of those members to customize how your applicationo
initializes. Y u must override InitMainWindow to have a useful application.o
T override a function in T pplication you need to derive your owno A
application class from T pplication.A
The T pplication constructor used here takes the application name as itsA
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. Y uro
application class’ constructor should call T pplication’ constructor TheA s .
following example shows a fragment of a T pplication-derived class:A
Chapter 3, Application objects
121