CONTROL ADD FRAME statement

Purpose

Add a frame to a dialog. This is also known as a "group" control, and is typically drawn around controls to indicate a visual association between such controls. A frame control is often used around related Option controls.

Syntax

Syntax CONTROL ADD FRAME, hDlg, id&, txt$, x, y, xx, yy [, [style&] [, [exstyle&]]]

hDlg 

Handle of the dialog in which the frame will be created. The dialog will become the parent of the control.

id&

Unique identifier for the control in the range 1 to 65535, frequently specified with numeric equates for clarity of the code. For example, the equate %RelatedItems is more informative than a literal value such as 497. If you will not be changing the text in a frame control after it is created, you may use -1 for the id&; however, best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers.

txt$

Text to be displayed in the frame. An ampersand (&) may be included in txt$ to specify a hot-key. See the Remarks section below.

x, y

Integer expressions, variables, or numeric literal values, specifying the location of the control inside the dialog client area. x is the horizontal position, and y is the vertical position. 0,0 refers to the upper left corner of the dialog box client area. Coordinates are specified in the same terms (pixels or dialog units) as the parent dialog.

xx 

Integer expression, variable, or numeric literal value, specifying the width of the control. The width is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 40 dialog units.

yy 

Integer expression, variable, or numeric literal value, specifying the height of the control. The height is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 14 dialog units.

style&

Primary style of the frame control. The default frame style comprises %BS_LEFT, and %BS_TOP. The default style is used only if both the primary and extended parameters are omitted from the statement. For example:

CONTROL ADD FRAME, hDlg, id&, txt$, 100, 100, 40, 14, , ' Use default styles

Custom style values replace the default values. That is, they are not additional to the default style values - your code must specify all necessary primary and extended style parameters.

The primary frame style value can be a combination of any values below, combined together with the OR operator to form a bitmask:

%BS_CENTER

Center the text horizontally in the frame.

%BS_LEFT

Place the text on the left side of the frame. (default)

%BS_GROUPBOX

Display a frame in which other controls can be positioned to infer a "visual association" or relationship between those controls. (persistent)

%BS_MULTILINE

Wrap the caption text across multiple lines if the text string is too long to fit on a single line. Wrapping is not automatic, but the line wrap position can be specified by inserting a $CR (or $CRLF) character at the desired wrap position in the caption text.

%BS_RIGHT

Place the text on the right side of the frame.

%BS_TOP

Place the text at the top of the frame. (persistent) Note: the %BS_TOP style is persistent - the frame control does not support %BS_BOTTOM alignment.

%WS_GROUP

Define the start of a group of controls. The first control in each group should also use %WS_TABSTOP style. The next %WS_GROUP control in the tab order defines the end of this group and the start of a new group. Groups configured this way permit the arrow keys to shift focus between the controls within the group, and focus can jump from group to group with the usual TAB and SHIFT+TAB keys. Both tab stops and groups are permitted to wrap from the end of the tab order back to the start.

%WS_DISABLED

Create a control that is initially disabled. A disabled frame control is displayed with grayed text.

exstyle&

Extended style of the frame control. The default extended frame style comprises %WS_EX_LEFT. The default extended style is used if both the primary and extended parameters are omitted from the CONTROL ADD FRAME statement, in the same manner as style& above.

The extended combo box style value can be a combination of any values below, combined together with the OR operator to form a bitmask:

%WS_EX_CLIENTEDGE

Apply a sunken edge border to the control.

%WS_EX_LEFT

The control has generic "left-aligned" properties. (default)

%WS_EX_RIGHT

The control has generic "right-aligned" properties. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading order alignment; otherwise, the style is ignored.

%WS_EX_STATICEDGE

Apply a three-dimensional border style to the control (intended to be used for items that do not accept user input).

%WS_EX_TRANSPARENT

Controls/windows beneath the control are drawn before the control is drawn. The control is deemed transparent because elements behind the control have already been painted - the control itself is not drawn differently. True transparency is achieved by using Regions - see MSDN for more information.

%WS_EX_WINDOWEDGE

Apply a raised edge border to the control.

Remarks

A frame control does not send messages to its parent dialog and does not require or support a Callback.

See also

Dynamic Dialog Tools, CONTROL GET TEXT, CONTROL SET TEXT