CONTROL ADD TOOLBAR statement

Purpose

Add a ToolBar control to a dialog.  A ToolBar overlays part of a dialog's client area, typically at the top.

Syntax

CONTROL ADD TOOLBAR, hDlg, ID, Txt$, x, y, nWide, nHigh [,style] [,exstyle&] [,CALL callback]

hDlg

Handle of the dialog in which the ToolBar 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 %PickList is more informative than a literal value such as 497. Best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers.

Txt$

Text to associate with the ToolBar control.  A ToolBar control does not display this text, so it is common to set this value to a null, empty string literal ("" or $NUL).

x,y

Integral expressions which specify the location of the control within the dialog client area.  In the case of a ToolBar, size parameters are ignored since the control is created with a default position.  These size parameters are usually omitted.

nWide, nHigh

Integral expressions which specify the overall width and height of the control.  In the case of a ToolBar, size parameters are ignored since the control is created with a default size.  These size parameters are usually omitted.

style

Optional primary style of the ToolBar control.  The default ToolBar style is %WS_CHILD or %WS_VISIBLE or %WS_BORDER or %CCS_TOP or %TBSTYLE_FLAT.  This default style is used if both the primary and extended style parameters are omitted from the statement, as in the following example:

CONTROL ADD TOOLBAR, hDlg, id&, "", 1, 1, 1, 1, , , CALL TBCallback()

If you include explicit style values, they replace the default values. That is, they are not added to the default styles values - your code must specify all necessary primary and extended style parameters.

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

%CCS_TOP

The ToolBar is placed at the top of the dialog.

%CCS_BOTTOM

The ToolBar is placed at the bottom of the dialog.

exstyle&

Optional extended style of the ToolBar control.  The extended ToolBar style value can be a combination of the 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_STATICEDGE

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

%WS_EX_WINDOWEDGE

Apply a raised edge border to the control.

callback

Optional name of a Callback Function that receives all %WM_COMMAND and %WM_NOTIFY messages for the control. See the #MESSAGES metastatement to choose which messages will be received. Generally speaking, ToolBar command messages result from clicking a ToolBar Button, so the message is sent to the callback specified in TOOLBAR ADD BUTTON or the dialog callback specified in DIALOG SHOW.  Message routing by button allows you to easily determine which button generated the event, and eliminates virtually all %WM_COMMAND messages here.  This callback is primarily used to process %WM_NOTIFY messages.

If the Callback Function processes a message, it should return TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists).  The dialog callback should also return TRUE if the notification message is processed by that Callback Function.  Otherwise, the DDT engine processes unhandled messages.

Remarks

When a Callback Function receives a message, it should explicitly test the value of CB.CTL and CB.CTLMSG to guarantee it is responding appropriately to the notification messages.

See also

DIALOG SHOW MODAL, DIALOG SHOW MODELESS, Dynamic Dialog Tools, CONTROL SET FONT, TOOLBAR