DLGTEMPLATE

Dialog Template

The DLGTEMPLATE defines the contents of a dialog box. This structure is divided into three distinct parts:

Part Description
Header Data Structure Contains a general description of the dialog box.
Font-Information Data Structure Defines the font with which text is drawn in the dialog box. This part is optional.
List of Items Describes the parts that compose the dialog box.

The CreateDialogIndirect, CreateDialogIndirectParam, DialogBoxIndirect, and
DialogBoxIndirectParam
functions use this structure.

Header Data Structure

The DLGTEMPLATE header is shown here:

typedef struct {

long dtStyle;

BYTE dtItemCount;

int dtX;

int dtY;

int dtCX;

int dtCY;

char dtMenuName[];

char dtClassName[];

char dtCaptionText[];

} DLGTEMPLATE;

The DLGTEMPLATE header has the following fields:

Field Description  
dtStyle Specifies the style of the dialog box. This field may be any or all of these values:  
  Value Meaning
  DS_LOCALEDIT Specifies that text storage for edit controls will be allocated in the application's local data segment. This allows the use of the EM_GETHANDLE and EM_SETHANDLE messages. If this style is not specified, edit-control data is located in a separate global data block.
  DS_SYSMODAL Specifies a system-modal dialog box.
  DS_MODALFRAME Specifies a dialog box with a modal dialog-box border. This style can be combined with the WS_CAPTION and WS_SYSMENU style flags to create a dialog box with a title bar and System menu.
  DS_ABSALIGN Indicates that dtX and dtY are relative to the screen origin, not to the owner of the dialog box.
  Value Meaning
  DS_SETFONT Specifies that a font other than the system font is to be used to draw text in the dialog box. If this flag is set, the FONTINFO data structure described in the following paragraphs must immediately follow the DLGTEMPLATE header.
    When Windows creates a dialog box with this attribute, Windows sends the WM_SETFONT message to the dialog-box window prior to creating the controls.
  DS_NOIDLEMSG Specifies that Windows will not send the WM_ENTERIDLE message to the owner of the dialog box while the dialog box is displayed.
dtItemCount Specifies the number of items in the dialog box. A dialog box can contain up to 255 controls.  
dtX Specifies the x-coordinate of the upper-left corner of the dialog box in units of 1/4 of the current dialog base width unit. The dialog base units are computed from the height and width of the current system font; the GetDialogBaseUnits function returns the current dialog base units in pixels. Unless DS_ABSALIGN is set in the dtStyle field, this value is relative to the origin of the parent window's client area.  
dtY Specifies the y-coordinate of the upper-left corner of the dialog box in units of 1/8 of the current dialog base height unit. Unless DS_ABSALIGN is set in the dtStyle field, this value is relative to the origin of the parent window's client area.  
dtCX Specifies the width of the dialog box in units of 1/4 of the dialog base width unit.  
dtCY Specifies the height of the dialog box in units of 1/8 of the dialog base height unit.  
dtMenuName[ ] Specifies a null-terminated string that specifies the name of the dialog box's menu. If this field is NULL, the dialog-box window does not have a menu.  
dtClassName[ ] Specifies a null-terminated string that supplies the name of the dialog box's class. If dtClassName[ ] is zero, it creates a dialog box with the standard dialog-box style. If an application specifies a class name, it should provide a dialog procedure that processes each dialog-box message directly or calls the DefDlgProc function to process the message. Also, the application must register the class with the cbWndExtra field of the WNDCLASS data structure set to DLGWINDOWEXTRA.  
dtCaptionText[ ] Specifies a null-terminated string that supplies the caption for the dialog box.  

Font-Information Data Structure

The FONTINFO data structure contains information about the point size and face name of the font which Windows is to use to draw text in the dialog box.

typedef struct{

short int PointSize;

char szTypeFace[]; /* A null-terminated string */

} FONTINFO;

The FONTINFO structure has the following fields:

Field Description  
PointSize Specifies the size of the typeface in points.  
szTypeFace Specifies the name of the typeface; for example, “Courier”.  

Comments

The font specified must have been previously loaded, either from WIN.INI or explicitly by calling the LoadFont function.

Item List

The item list consists of one or more DLGITEMTEMPLATE data structures, one for each control in the dialog box. The first such structure immediately follows the FONTINFO structure or the header at the first byte after the terminating null character in the szTypeFace field or the dtCaptionText[ ] field. The following shows the format of the DLGITEMTEMPLATE structure.

typedef struct {

int dtilX;

int dtilY;

int dtilCX;

int dtilCY;

int dtilID;

long dtilStyle;

char dtilClass[];

char dtilText[];

BYTE dtilInfo;

PTR dtilData;

} DLGITEMTEMPLATE

The DLGITEMTEMPLATE data structure has the following fields:

Field Description  
dtilX Specifies the x-coordinate of the upper-left corner of the dialog-box item in units of 1/4 of the current dialog base width unit, relative to the origin of the dialog box. The dialog base units are computed from the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog base units in pixels.  
dtilY Specifies the y-coordinate of the upper-left corner of the dialog-box item in units of 1/8 of the current dialog base height unit. This value is relative to the origin of the dialog box.  
dtilCX Specifies the width-extent of the dialog-box item in units of 1/4 of the current dialog base width unit. Dialog base units are computed from the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog base units.  
dtilCY Specifies the height of the dialog-box item in units of 1/8 of the dialog base height unit.  
dtilID Specifies the dialog-box item identification number.  
dtilStyle Specifies the style of the dialog-box item.  
dtilClass[ ] A null-terminated string that specifies the control's class. It may be one of the following class names:  
  BUTTON
EDIT
STATIC
LISTBOX
SCROLLBAR
COMBOBOX
 
dtilText[ ] Specifies the text for the item; it is a null-terminated string.  
dtilInfo Specifies the number of bytes of additional data that follows this item description and precedes the next item description.  
dtilData Specifies additional data which the CreateWindow function receives through the lpCreateParams field of the CREATESTRUCT data structure. This field is zero length if dtilInfo is zero.