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

Dialog boxes are designed and created using dialog box resources.

You can use Borland's Resource Workshop or any other resource editor to create dialog box resources and bind them to your application. A dialog box resource describes the appearance and location of controls, such as buttons, list boxes, group boxes, and so on, but is not responsible for the behavior of the dialog box. That is the responsibility of the application. Each dialog box resource has an identifier that enables a dialog box object to specify which dialog box resource it uses. The identifier can be either a string or an integer. You pass this identifier to the dialog box constructor to specify which resource the object should use.

Calling the constructor

To construct a dialog box object, create it using a pointer to a parent window object and a resource identifier (the resource identifier can be either string or integer based) as the parameters to the constructor:

TDialog dialog1(this, "DIALOG_1");
TDialog dialog2(this, IDD_MY_DIALOG);

The parent window is almost always this because you normally construct dialog box objects in a member function of a window object. If you do not construct a dialog box object in a window object, use the application's main window as its parent as shown in the following code sample, because that is the only window object always present in an ObjectWindows application:

TDialog
mySpecialDialog(GetApplication()->GetMainWindow(), IDD_DLG);

The exception to this parent window behavior is when you specify a dialog box object as a client window in a TFrameWindow or TFrameWindow-based constructor. The constructor passes the dialog box object to the TFrameWindow::Init() function, which automatically sets the parent of the dialog box. (See Using a dialog box as your main window for an example.)

See Also