The DIALOG resource

The syntax for the DIALOG resource is:-

nameID DIALOG x, y, width, height

[defining-statements] [dialog-statements]
BEGIN
iconcontrol
textcontrol
non-textcontrol
generic-control
END

The syntax for the DIALOGEX resource is:-

nameID DIALOGEX x, y, width, height [,helpID]
[defining-statements]
[dialog-statements]
BEGIN
iconcontrol
textcontrol [,helpID]
non-textcontrol [,helpID]
generic-control [,helpID]
END

Where,
nameID can be either:-

a 16-bit number of value 1 to 7FFFh
an expression which evaluates to that number
a name

x is the horizontal position of the dialog in dialog units
y is the vertical position of the dialog in dialog units
width is the width of the dialog in dialog units
height is the height of the dialog in dialog units helpID which is used in DIALOGEX only, is a value which is sent to the dialog procedure if F1 is pressed when the dialog is active. A helpID specified for a control is sent if the user clicks the control after having dragged the help question mark. helpID can be:- a 32-bit number
an expression which evaluates to a 32 bit number

defining-statements need not be present, but can be either:- a VERSION statement
a CHARACTERISTICS statement
a LANGUAGE statement
see below for details

dialog-statements need not be present, but can be one or more of the following:- CAPTION "text"
where "text" is the title of the dialog to insert in the title bar

CLASS class
this statement is used if you have registered your own private window class for the dialog because you want to intercept dialog messages before they go to the system’s default dialog window procedure. class can be:-
a 16-bit number
a quoted string

EXSTYLE exstyle allows an extended style to be specified see window types and styles

FONT pointsize, "typeface" ;if DIALOG
FONT pointsize, "typeface" [,weight, italic, charset] ;if DIALOGEX
this statement must be present if the dialog has the DS_SETFONT style and it contains the information which the system uses to write the text within the dialog box and its controls. If this statement is present the dialog box is given the style DS_SETFONT automatically.
pointsize is a 16 bit number giving the size of the font
typeface is a quoted string giving the name of the typeface
weight (DIALOGEX only) is either:-

a 16 bit number
an expression which evaluates to a 16 bit number
one of the words known to the Resource Compiler set out below (the weight is given in the second column) FW_DONTCARE 0
FW_THIN 100
FW_EXTRALIGHT 200
FW_LIGHT 300
FW_NORMAL 400
FW_MEDIUM 500
FW_SEMIBOLD 600
FW_BOLD 700
FW_EXTRABOLD 800
FW_HEAVY 900
if this parameter is omitted it is set to zero (don’t care)

italic (DIALOGEX only) indicates whether italics should be used and is either:- the number 0 or the word FALSE to indicate not italic, or
the number 1 or the word TRUE to indicate italic
if this parameter is omitted it is set to zero (non-italic)

charset (DIALOGEX only) indicates the character set for the dialog and is either:- an 8 bit number
an expression which evaluates to an 8 bit number
one of the words known to the Resource Compiler set out below (the value is given in the second column) ANSI_CHARSET 0
DEFAULT_CHARSET 1
SYMBOL_CHARSET 2
SHIFTJIS_CHARSET 128
HANGEUL_CHARSET 129
HANGUL_CHARSET 129
GB2312_CHARSET 134
CHINESEBIG5_CHARSET 136
OEM_CHARSET 255
JOHAB_CHARSET 130
HEBREW_CHARSET 177
ARABIC_CHARSET 178
GREEK_CHARSET 161
TURKISH_CHARSET 162
VIETNAMESE_CHARSET 163
THAI_CHARSET 222
EASTEUROPE_CHARSET 238
RUSSIAN_CHARSET 204
MAC_CHARSET 77
BALTIC_CHARSET 186
if this parameter is omitted it is set to zero (don’t care)

MENU menuname
this statement if present specifies a menu for the dialog box and menuname is either:-
a 16-bit number identifying the menu. This would be the number given as the nameID of the menu resource.
an expression which evaluates to that number, or
the name of a menu resource if the nameID of the menu was a name

STYLE styles
this statement is used to change the default dialog box style which is:-
WS_POPUP | WS_BORDER | WS_SYSMENU, which is the same as 80000000h | 800000h | 80000h
To remove an unwanted default style you can use the word NOT or !, for example
STYLE NOT SYSMENU
or
STYLE !80000h
would produce a dialog box with a style of WS_POPUP and WS_BORDER only.
The following styles and their respective values can be used in this statement:-

DS_MODALFRAME (value 80h) creates a dialog box with a modal dialog frame (can be combined with WS_CAPTION and WS_SYSMENU styles)
DS_SYSMODAL (value 2h) gives the dialog box the WS_EX_TOPMOST style
WS_BORDER (value 800000h) creates a dialog box with a border
WS_DLGFRAME (value 400000h) creates a modal dialog box type of frame for the dialog but no title bar
WS_OVERLAPPED (value zero) see window types and styles
WS_OVERLAPPEDWINDOW see window types and styles
WS_POPUPWINDOW see window types and styles
WS_CAPTION (value 0C00000h) combination of WS_BORDER and WS_DLGFRAME see window types and styles
WS_POPUP (value 80000000h) see window types and styles
WS_CHILD (value 40000000h) see window types and styles
WS_CLIPCHILDREN (value 2000000h) see window types and styles
WS_CLIPSIBLINGS (value 4000000h) see window types and styles
WS_MINIMIZEBOX (value 20000h) dialog box has a minimizebox in the title bar
WS_MAXIMIZEBOX (value 10000h) dialog box has a maximizebox in the title bar
WS_HSCROLL (value 100000h) creates a dialog with a horizontal scroll bar
WS_VSCROLL (value 200000h) creates a dialog box with a vertical scroll bar
WS_SIZEBOX (value 40000h) creates a dialog box with a thick frame for resizing
WS_MINIMIZE (value 20000000h) dialog box is created minimized
WS_MAXIMIZE (value 1000000h) dialog box is creates maximized
WS_SYSMENU (value 80000h) creates a dialog box with a system menu in its title bar
WS_DISABLED (value 8000000h) dialog is initially disabled
DS_NOIDLEMSG (value 100h) suppresses WM_ENTERIDLE messages that the system would otherwise send to the owner of the dialog box
DS_ABSALIGN (value 1h) - the co-ordinates of the dialog box are screen co-ordinates as opposed to client co-ordinates
DS_CENTER (value 800h) centre the dialog box as far as possible on the screen
DS_CENTERMOUSE (value 1000h) centre the mouse cursor in the dialog box
DS_CONTEXTHELP (value 2000h) add a question mark to the title bar for help processing
DS_CONTROL (value 400h) make the dialog box work like the child window of another dialog box
DS_FIXEDSYS (value 8h) use the system’s fixed font rather than the proportional font
DS_SETFONT (value 40h) look for the FONT statement for the font to use for the controls and for text in the dialog box
DS_NOFAILCREATE (value 10h) make the dialog box even if there are errors in making the controls
DS_SETFOREGROUND (value 200h) system to call SetForegroundWindow when the dialog is created

an iconcontrol displays an icon in the dialog box

The syntax for an iconcontrol is:-
ICON nameID, id, x, y
Where, nameID is the identifier of an ICON resource and it is either:-

a 16-bit number of value 1 to 7FFFh
an expression which evaluates to that number
a quoted string containing the name of the ICON if the icon is identified by name

x is the horizontal position of the icon
y is the vertical position of the icon id can be:-
a 16-bit number (DIALOG) or a 32-bit number (DIALOGEX)
an expression which evaluates to the above number

a textcontrol is a dialog control which contains text and which has a name which is recognised by the Resource Compiler. The name of the type of control causes the Resource Compiler to give the control the correct class and a default style. To remove a default style you will need to use the NOT specifier, as you would to remove a default style for the dialog itself.

The syntax for a textcontrol is:-
textcontrol "text", id, x, y, width, height, [,style [,extendedstyle]]
BEGIN
data-elements
END
Where,
"text" is the text to appear in the control

id can be:-
a 16-bit number (DIALOG) or a 32-bit number (DIALOGEX)
an expression which evaluates to the above number

x is the horizontal position of the control in dialog units
y is the vertical position of the control in dialog units
width is the width of the control in dialog units
height is the height of the control in dialog units data-elements are one or more elements of data, called "Creation data". A pointer to this data is sent to the dialog procedure in the lParam parameter of the WM_CREATE message when the control is created. The data is made using the same format as for the RCDATA resource.


The various textcontrols and their classes are given below, together with the default styles LTEXT - static class, default style SS_LEFT and WS_GROUP creating a static control with left aligned text
CTEXT - static class, default style SS_CENTER and WS_GROUP creating a static control with centred text
RTEXT- static class, default style SS_RIGHT and WS_GROUP creating a static control with right-aligned text
GROUPBOX - button class, default style BS_GROUPBOX creates a labelled rectangle in the dialog box inside which other controls can be grouped
CHECKBOX - button class, default style BS_CHECKBOX and WS_TABSTOP which creates a check box control (small rectangle with text next to it)
AUTOCHECKBOX - button class, default style BS_AUTOCHECKBOX and WS_TABSTOP which creates check box control which automatically changes to checked or unchecked when the user clicks in the control
STATE3 - button class, default style BS_3STATE and WS_TABSTOP which creates a check box control which has 3 states - checked, unchecked and disabled (greyed)
AUTO3STATE - button class, default style BS_AUTO3STATE and WS_TABSTOP which creates a STATE3 control which automatically toggles when clicked between the 3 states
RADIOBUTTON - button class, default style BS_RADIOBUTTON and WS_TABSTOP which creates a radio button control
AUTORADIOBUTTON - button class, default style BS_AUTORADIOBUTTON and WS_TABSTOP which creates an automatic radio button
PUSHBUTTON - button class, default style BS_PUSHBUTTON and WS_TABSTOP creates an ordinary push button control containing text
DEFPUSHBUTTON - button class, default style BS_DEFPUSHBUTTON and WS_TABSTOP creates an ordinary push button control containing text and showing as the default if the user presses enter
PUSHBOX - button class, default style BS_USERBUTTON, BS_CHECKBOX and WS_TABSTOP giving a flat appearance to the button

a non-textcontrol is similar to a textcontrol except that it does not contain text in the first instance (this must be added at run-time).

The syntax for a non-textcontrol is:-
non-textcontrol id, x, y, width, height, [,style [,extendedstyle]]
BEGIN
data-elements
END

The id, x, y, width, height, style and extend style parameters are the same as for the text-control
The various non-textcontrols and their classes are given below, together with the default styles

EDITTEXT - edit class, default style ES_LEFT, WS_BORDER and WS_TABSTOP which creates a simple edit control
HEDIT handwriting edit (pen) control
IEDIT ink edit (pen) control
LISTBOX - listbox class, default style LBS_NOTIFY and WS_BORDER creating a basic listbox
SCROLLBAR - scrollbar class, default style SBS_HORZ creating a basic scrollbar
COMBOBOX - combobox class, default style CBS_SIMPLE creating a basic combobox control

a generic-control is a control where you explicitly specify the class of the control. It is mainly used for those control classes which do not come into the button, edit, static, listbox, scrollbar or combobox classes. However, you can use the generic-control syntax to make those controls too.

The syntax for the generic-control is as follows:-
CONTROL "text", id, class, style, x, y,width,height [,extended style] [,helpID]

BEGIN
data-elements
END

The id, x, y, width, height, style and extend style parameters are the same as for the text-control
"text" is:- a quoted string containing the text for the control or "" if it has no text
in the case of a control of the static class which has the SS_BITMAP style, "text" can be a 16 bit number representing the bitmap concerned
an expression which evaluates to the above text or number

class is:- (if one of the first six in the list below) a 16-bit number of value 80h to 85h
an expression which evaluates to the above number
a quoted string containing the name of the class shown in the second column of the list below, or
a word shown in the first column of the list below
or (for a user-defined class) a quoted string
The class can therefore be one of the following:- BUTTON "Button" ;value 80h
EDIT "Edit" ;value 81h
STATIC "Static" ;value 82h
LISTBOX "Listbox" ;value 83h
SCROLLBAR "Scrollbar" ;value 84h
COMBOBOX "ComboBox" ;value 85h
WC_HEADER "SysHeader32"
WC_LISTVIEW "SysListView32"
WC_TREEVIEW "SysTreeView32"
HOTKEY_CLASS "msctls_hotkey32"
UPDOWN_CLASS "msctls_updown32"
ANIMATE_CLASS "SysAnimate32"
WC_COMBOBOXEX "ComboBoxEx32"
WC_TABCONTROL "SysTabControl32"
MONTHCAL_CLASS "SysMonthCal32"
PROGRESS_CLASS "msctls_progress32"
REBARCLASSNAME "ReBarWindow32"
TOOLTIPS_CLASS "tooltips_class32"
TRACKBAR_CLASS "msctls_trackbar32"
STATUSCLASSNAME "msctls_statusbar32"
TOOLBARCLASSNAME "ToolbarWindow32"
DATETIMEPICK_CLASS "SysDateTimePick32"
WC_IPADDRESS "SysIPAddress32"
WC_PAGESCROLLER "SysPager"
WC_NATIVEFONTCTL "NativeFontCtl"
DRAGLISTMSGSTRING "commctrl_DragListMsg"

For the controls which do not normally take initial text, (see non-textcontrols above) you must include an empty text string by specifying "", for the text parameter.
style and extendedstyle are chosen to suit the particular control being made. Note that there are no default styles, other than WS_CHILD and WS_VISIBLE.

Example of a DIALOGEX resource
0x45 DIALOGEX 0x30, 0x20, 0x200, 0x400,0x98
CAPTION "goodbye"
MENU mymenu
FONT 10,"Times New Roman",FW_NORMAL,1
BEGIN

CTEXT "hello", 0x20,0x10,0x10,0x10,0x10,
,WS_EX_PALETTEWINDOW, 0x333
COMBOBOX 0x456,30005,4560,300,20
BEGIN 0x888888L
L"hello folks"
0x99,0x67,0x5555
END CONTROL "ducks",0x460,"ComboBoxEx32",0x100,30005,4560,300,20 CONTROL "drakes",0x461,0x85,0x100,30005,4560,300,20
CONTROL "hens",0x462,"Button",0x100,30005,4560,300,20 CONTROL "and",0x463,"Own class",0x100,30005,4560,300,20
CONTROL "chickens",0x464,STATUSCLASSNAME, 0x100,30005,4560,300,20
ICON "ANI_ICON",0x465, 6, 9, 18, 20
END


Example of a DIALOG resource
AboutBox DIALOG 100, 100, 160, 72
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
FONT 8,"MS Sans Serif"
CAPTION "About it"
BEGIN CTEXT "Application" -1, 0, 8, 160, 8
CTEXT "Version 1.2" -1, 0, 16, 160, 8
DEFPUSHBUTTON "OK" IDOK, 55,52,50,14
CONTROL 23h,-1,"Static",SS_BITMAP,9,6,125,41
ICON "MyIcon" -1, 20, 10,0,0
END

Defining statements

defining-statements give some further definition to each resource.
There are three types of defining-statement:- VERSION statement
CHARACTERISTICS statement
LANGUAGE statement

Each defining-statement is specific to the resource to which it refers, however if LANGUAGE is specified outside a specific resource it will apply to all resources thereafter.