Custom toolbars
To present a group of tool buttons that represent built-in commands, user-defined commands, or a combination of both, use a custom toolbar. Custom toolbars can also contain drop-down tool buttons that support multiple commands. When the arrow on a drop-down tool button is clicked, the button displays a menu of additional tool buttons instead of launching a command. Clicking a tool button in the menu launches the button's command. The following screen shot shows a custom toolbar that contains a combination of user-defined commands, drop-down tool buttons, and built-in commands:
Toolbars are represented by toolbar objects in the ArcPad object model and by TOOLBAR elements in ArcPad XML.
Attributes
The following toolbar attributes are set at design time in ArcPad Studio in the Toolbar dialog box. They cannot be changed at run time (some attributes have corresponding properties that can be accessed and changed at run time). Attributes are written to the customization file (.apa or arcpad.apx) in ArcPad XML format.
- name—Name of the toolbar. Used to reference the toolbar in scripts.
- buttonsize—Scale factor for the size of buttons on the toolbar.
- caption—Text on the toolbar.
- image—Image to the left of the toolbar.
- visible—Specifies whether the toolbar is visible or hidden.
Events
Toolbars do not generate events.
Properties
Toolbar properties can be read and set at run time via scripts. The following toolbar properties are available:
- Caption—Caption of the toolbar.
- Count—Number of tool item objects on the toolbar.
- hWnd—Window handle of the toolbar.
- Name—Name of the toolbar.
- Visible—Value that determines whether the toolbar is visible.
Methods
Toolbar methods can be called at run time via scripts. The following toolbar method is available:
- Item—Specified tool item object.
Reference a toolbar
You can reference any toolbar that is currently loaded, regardless of whether or not it is visible. You reference a toolbar via its name. For example, to reference a toolbar named "tlbTools", see the following sample code:
VBScript
Dim objToolbar Set objToolbar = Application.Toolbars("tlbTools")
JScript
var objToolbar = Application.Toolbars("tlbTools");
Python
objToolbar = Application.Toolbars("tlbTools")
The names of the default toolbars are as follows:
- Main Toolbar (Main)
- Browse Toolbar (Browse)
- Edit/Draw Toolbar (Draw)
- QuickCapture Toolbar (QuickCapture)
- Navigation Toolbar (Navigation)
Display or hide a toolbar
To display or hide a toolbar, reference the toolbar and set its Visible property to true or false, respectively. For example, to display a toolbar named "tlbTools", see the following sample code:
VBScript
Application.Toolbars("tlbTools").Visible = True
JScript
Application.Toolbars("tlbTools").Visible = true;
Python
Application.Toolbars("tlbTools").Visible = True
To hide the same toolbar, see the following sample code:
VBScript
Application.Toolbars("tlbTools").Visible = False
JScript
Application.Toolbars("tlbTools").Visible = false;
Python
Application.Toolbars("tlbTools").Visible = False
Change a toolbar's caption
To change a toolbar's caption, reference the toolbar and set its Caption property to the desired text string. For example, to change the caption of a toolbar named "tlbTools" to "New Caption", see the following sample code:
VBScript
Application.Toolbars("tlbTools").Caption = "New Caption"
JScript
Application.Toolbars("tlbTools").Caption = "New Caption";
Python
Application.Toolbars("tlbTools").Caption = "New Caption"