OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Using a dialog box as your main window

To use a dialog box as your main window, it is best to make the main window a frame window that has your dialog box as a client window.

To do this, derive an application class from TApplication. Aside from a constructor, the only function necessary for this purpose is InitMainWindow. In the InitMainWindow function, construct a frame window object, specifying a dialog box as the client window. In the five-parameter TFrameWindow constructor, pass a pointer to the client window as the third parameter. Your code should look something like this:

#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dialog.h>
class TMyApp : public TApplication
{
public:
TMyApp(char *title) : TApplication(title) {}
void InitMainWindow();
};
void TMyApp::InitMainWindow()
{
SetMainWindow(new TFrameWindow(0, "My App", new TDialog(0, "MYDIALOG"), true));
}
int OwlMain(int argc, char* argv[])
{
return TMyApp("My App").Run();
}
Definition of class TApplication.
Definition of TDialog class and TDialogAttr struct.
Definition of class TFrameWindow.
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

The TFrameWindow constructor turns autocreation on for the dialog box object that you pass as a client, regardless of the state you pass it in.

You also must make sure the dialog box resource has certain attributes:

  • Destroying your dialog object does not destroy the frame. You must destroy the frame explicitly.
  • You can no longer dynamically add resources directly to the dialog, because it is not the main window. You must add the resources to the frame window. For example, suppose you added an icon to your dialog using the SetIcon function. You now must use the SetIcon function for your frame window.
  • You cannot specify the caption for your dialog in the resource itself anymore. Instead, you must set the caption through the frame window.
  • You must set the style of the dialog box as follows:
    • Visible (WS_VISIBLE)
    • Child window (WS_CHILD)
    • No Minimize and Maximize buttons, drag bars, system menus, or any of the other standard frame window attributes

See Also