DIALOG Statement

The DIALOG statement defines a template that can be used by an application to create dialog boxes.

Summary: Syntax

nameID DIALOG [[loadoption]] [[memoption]]x, y, width, height
[[optionstatements]]
BEGIN
controlstatements
END

This statement marks the beginning of a DIALOG template. It defines the name of the dialog box, the memory and load options, the box's starting location on the display screen, and the box's width and height.

The nameID field specifies either a unique name or an integer value that identifies the resource.

The optional loadoption field takes a keyword that specifies when the resource is to be loaded. It must be one of the following:

PRELOAD

Resource is loaded immediately.

LOADONCALL

Resource is loaded when called. This is the default option.

The optional memoption field takes the following keyword or keywords, which specify the memory status of the resource:

FIXED

Resource remains at a fixed memory location.

MOVEABLE

Resource can be moved if necessary to compress memory. This is the default option.

DISCARDABLE

Resource can be discarded if no longer needed.

The x and y fields take integer values that specify the x and y coordinates of the upper-left corner of the dialog box. The horizontal units are 1/4 of the dialog base width unit; the vertical units are 1/8 of the dialog base height unit. The current dialog base units are computed from the height and width of the current system font. The GetDialogBaseUnits function returns the dialog base units in pixels. The exact meaning of the coordinates depends on the style defined by the STYLE option statement. For child-style dialog boxes, the coordinates are relative to the origin of the parent window, unless the dialog box has the style DS_ABSALIGN; in that case, the coordinates are relative to the origin of the display screen.

The width and height fields take integer values that specify the width and height of the box. The width units are 1/4 of the dialog base width unit; the height units are 1/8 of the dialog base height unit.

The option and control statements are described in the following sections.

The following example demonstrates the correct usage of the DIALOG statement:

#include “WINDOWS.H”

errmess DIALOG 10, 10, 300, 110

STYLE WS_POPUP|WS_BORDER

CAPTION “Error!”

BEGIN

CTEXT “Select One:”, 1, 10, 10, 280, 12

RADIOBUTTON “&Retry”, 2, 75, 30, 60, 12

RADIOBUTTON “&Abort”, 3, 75, 50, 60, 12

RADIOBUTTON “&Ignore”, 4, 75, 80, 60, 12

END

Summary: Comments

Do not use the WS_CHILD style with a modal dialog box. The DialogBox function always disables the parent/owner of the newly created dialog box. When a parent window is disabled, its child windows are implicitly disabled. Since the parent window of the child-style dialog box is disabled, the child-style dialog box is too.

If a dialog box has the DS_ABSALIGN style, the dialog coordinates for its upper-left corner are relative to the screen origin instead of to the upper-left corner of the parent window. You would typically use this style when you wanted the dialog box to start in a specific part of the display no matter where the parent window may be on the screen.

The name DIALOG can also be used as the class-name parameter to the CreateWindow function in order to create a window with dialog-box attributes.