# Toolbar Control
> [HTML Version](toolbarcontrol.htm)
_Updated November 2013; see History_
The toolbar control (_ctype_ MBF\_TOOLBAR) is a standard Windows control which acts as a container for buttons. It is attached to one of the four edges of the parent window. Although created with the standard AUI\_CONTROL function, toolbars differ from other controls in the following ways:
• The coordinates specified when creating a toolbar are ignored; position is determined by the CCS\_xxx option set in the _winstyle_ parameter, which selects the edge of the parent window to which the toolbar will be attached. The thickness of the bar is determined by the size of the images, labels, and style.
• Toolbars do not scale with changes in size to the parent window. Instead, they only stretch to match the length of the window edge to which they are attached.
• Toolbars do not take up space within the main window grid. Instead, the grid itself adjusts to make room for the toolbar.
• Toolbars are not removed by the tab(-1,0) command, unless they were created with the MBF\_UNPROTECTED flag. They must be removed explicitly by AUI\_CONTROL with the CTLOP\_DEL opcode.
• There is a maximum of four toolbars per parent window, one for each edge.
• Currently, toolbars may only be created in the main window. This restriction may be lifted later.
You can also create toolbar-like controls or panels using standard buttons or icons, either positioned manually in a row along one edge of the screen, or contained within a floating dialog (i.e. a floating tool panel).
Several example programs and PNG images are included in the [EXLIB:\[908,58\]](https://bitbucket.org/microsabio/exlib/src/master/908058/).
**Examples**
See A-Shell Screen Elements for an extreme example with all four toolbars in use. Other examples:
| | |
|------|------|
| 16x16 buttons in top
toolbar with tooltips: | _(./images/ashref_img158.png)_ |
| 24x24 buttons in bottom toolbar with labels beneath (TBSTYLE\_FLAT): | _(./images/ashref_img159.png)_ |
| 24x24 buttons with labels to side (TBSTYLE\_LIST), with one disabled button: | _(./images/ashref_img160.png)_ |
**Syntax and Parameters**
Like the TabX Control, the Toolbar is largely configured via the AUI\_CONTROL [ctext](ctext.htm.md) parameter using the following syntax:
**ctext = \{@toolbarattribs~~\}\{opcur\}\{btndef~~btndef~~...btndef~~\}**
_opcur_
identifies the operation and button when modifying an existing toolbar. If present it must start with a "+" or "=" and end with a ":", according to the following:
| **opcur** | **Description** |
|------|------|
| _\+:_ | Append subsequent _btndef_s to the end of the toolbar |
| _\-labelid:_ | Modify the button whose _id_ or _cmd_ attribute matches the specified l_abelid_. |
_toolbarattribs_
defines attributes of the toolbar as a whole, most importantly the image size info. Starts with a @ and ends with ~~, between which you may have any number of = pairs separated a single tilde, i.e.:
@=~=~...=~~
| **Attrib** | **Value** | **Description** |
|------|------|------|
| ImgSiz | ,, | width, height (in pixels), bits per pixel. All images for the toolbar will be scaled to the specified size (although the quality will be best if the original images are already of the specified size). For bpp < 32, you must specify the MBF2\_GDIPLUS _ctype2_ flag when creating the control in order to support some of the more advanced options, like the automatic transparency and ImgDis/ImgHot features. |
| ImgDir |
or
standard icon set id | (optional) Default location for images, which avoids need to specify the full directory for each individual image. May be in native format (e.g. ImgDir=c:\\images\\toolbars) with or without %env% variables, or DevPPN format. Note that A-Shell and ATE will also look in their own default locations if not found here. To use one of the standard icon sets built in to Windows, specify the id # here in place of a directory; see Using Windows Native Icons below. |
| ImgCount | \# of images to expect | (optional) estimate of the number of images in the toolbar. Simply improves the efficiency of memory allocation operations. |
| ImgDis | \{,\} | (optional) Rendering OPtion and suffix for disabled version of images. Rop 0 is the standard Windows scheme; 1 uses an A-Shell alternate algorithm for generating the disabled/gray version of the image. If the suffix is specified, A-Shell looks for an alternate image file to use for the disabled image. For example, if the img file is clickme.png and is \_d, then it will look for clickme\_d.png. See following topic [Disabled and Hot Images](disabledandhotimages.htm.md). |
| ImgHot | \{,\} | (optional) Rendering OPtion and suffix for hot version of images. Same concept as for ImgDis except for the "hot" version of the image (displayed when the mouse is hovering over it). See following topic [Disabled and Hot Images](disabledandhotimages.htm.md). |
_btndefs_
define each individual button. Each _btndef_ clause is made up of a series of = pairs, each delimited by a single tilde with the entire clause terminated by a double tilde, i.e.:
=~=~...=~~
| **Attrib** | **Value** | **Description** |
|------|------|------|
| img | Image specification
or
standard icon id | The image to load for the button. If no directory specified, the default directory (see ImgDir in the _toolbarattribs_) is used. Note that only discrete PNG files are properly supported. If using standard built-in icons, specify the icon id number instead of the image file specification; see Using Windows Native Icons below. |
| cmd | command string | May be any of the following:
keyboard client string (e.g. VK\_xF201, VK\_ESCAPE, etc.)
MENUID: