Control Styles

When creating child controls for your dialogs, you are free to use almost any control style permitted by Windows. These styles mostly start with the %WS_ prefix (Window Style), and are included in the WIN32API.INC file included in your WINAPI directory.

If the style parameter in your CONTROL ADD statements is set to 0, DDT will set default styles automatically for you. The default styles will depend on the type of control you are adding to your dialog. For example, a button will be given the %WS_TABSTOP style.

Note that DDT always gives your controls certain styles, such as %WS_CHILD and %WS_VISIBLE, regardless of the styles you specify. When setting your style parameter, you can safely ignore these two styles and concentrate on the more important styles that are required. This has the advantage of reducing the clutter of your code. The exception is custom controls - in this case you must explicitly specify all required styles.

The "tab-order" of controls (also known as the "z-order") is determined by the order that DDT controls are created at run-time. That is, the first control added to a dialog is the first control in the z-order, the second control added is second, and so forth. When a dialog is initially displayed, keyboard focus is automatically given to the first control in the z-order that has the %WS_TABSTOP style. Each time the TAB key is subsequently pressed, the keyboard focus moves to the next control in the tab-order. To ensure all controls in a dialog can be selected using the TAB key, each control in the dialog should include the %WS_TABSTOP style. The z-order also determines the order that controls are drawn on a dialog, to help ensure that control that overlap one another can be drawn in a predictable manner.

Controls that are disabled (because either they have the %WS_DISABLED style or they have been dynamically disabled with CONTROL DISABLE) are skipped over.

Most DDT controls are created with the %WS_TABSTOP style by default. However, you should explicitly include the %WS_TABSTOP style in the control style parameter, if your DDT code creates controls with custom (non-default) styles. If you do not include this style, these control(s) may not be able to receive keyboard focus.

The following table lists the default DDT styles for many of the standard controls:

Control type

Default DDT Styles *

Hex Value

BUTTON

%WS_TABSTOP

50010000

CHECK3STATE

%WS_TABSTOP, {%BS_AUTO3STATE}

50010006

CHECKBOX

%WS_TABSTOP, {%BS_AUTOCHECKBOX}

50010003

COMBOBOX

%WS_TABSTOP, %CBS_SORT, %CBS_DROPDOWN, {%CBS_HASSTRINGS}

50010302

FRAME

%BS_LEFT, {%BS_TOP, %BS_GROUPBOX}

50000507

IMAGE

either {%SS_ICON}

or {%SS_BITMAP}

50000003

5000000E

IMAGEX

either {%SS_ICON}

or {%SS_BITMAP}

50000003

5000000E

IMGBUTTON

either %WS_TABSTOP, {%BS_ICON}

or %WS_TABSTOP, {%BS_BITMAP}

50010040

50010080

IMGBUTTONX

either %WS_TABSTOP, {%BS_ICON}

or %WS_TABSTOP, {%BS_BITMAP}

50010040

50010080

LABEL

%SS_LEFT

50000000

LINE

%SS_ETCHEDFRAME

50000012

LISTBOX

%WS_TABSTOP, %LBS_SORT, %LBS_NOTIFY, %WS_VSCROLL

50210003

OPTION

%WS_TABSTOP, {%BS_AUTORADIOBUTTON}

50010009

SCROLLBAR

either {%SBS_HORZ}

or {%SBS_VERT}

50000000

50000001

TEXTBOX

%WS_TABSTOP, %WS_BORDER, %ES_AUTOHSCROLL, %ES_LEFT

50810080

"custom control"

No default style (%WS_CHILD and %WS_VISIBLE not used)**

0

 

See Also

Dynamic Dialog Tools (DDT)

Creating a Dialog

Adding Controls to the Dialog

Modal vs. Modeless

Controls

Callbacks

Dialog Styles

Menus