OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Initializing the main window

By default, TApplication::InitMainWindow() creates a frame window with the same name as the application object.

This window is not very useful, because it cannot receive or process any user input. You must override InitMainWindow to create a window object that does process user input. Normally, your InitMainWindow function creates a TFrameWindow or TFrameWindow-derived object and calls the SetMainWindow function, a protected member function of TApplication. SetMainWindow takes one parameter, a pointer to a TFrameWindow object, and returns a pointer to the old main window. (If this is a new application that has not yet set up a main window, the return value is zero). The following example shows a simple application that creates a TFrameWindow object and makes it the main window:

#include <owl\applicat.h>
#include <owl\framewin.h>
class TMyApplication: public TApplication
{
public:
TMyApplication(char *name):TApplication(name) {}
virtual void InitMainWindow();
};
void
TMyApplication::InitMainWindow()
{
SetMainWindow(new TFrameWindow"(0, "My First Main Window"));
}
int
OwlMain(int argc, char* argv[])
{
return TMyApplication("Wow!").Run();
}
Definition of class TApplication.
Definition of class TFrameWindow.

When you run this application, the caption bar is titled "My First Main Window," and not "Wow!". The application name passed in the TApplication constructor is used only when you do not provide a main window. Once again, this example doesn't do a lot; there is still no provision for the frame window to process any user input. But once you have derived a window class that does interact with the user, you use the same simple method to display the window.

See Also