From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from DesktopUIControl)

New in 2021r3

Used to create a toolbar in a window. The DesktopToolbar control is supported on all desktop platforms.

Closing MenuItemSelected Opening
ContextualMenuItemSelected MouseDown Pressed
FocusLost MouseDrag
FocusReceived MouseUp
AllowAutoDeactivate Left Transparent
AllowTabStop Name fa-lock-32.png Visible
Enabled Parent Width
Handle fa-lock-32.png Tooltip Window fa-lock-32.png
Height Top
AcceptFileDrop AddButtonAt Refresh
AcceptPictureDrop ButtonAt RemoveButtonAt
AcceptRawDataDrop Close SetFocus
AcceptTextDrop Count
AddButton DrawInto


A DesktopToolbar object contains all the buttons in a toolbar. You create the items in the toolbar with the DesktopToolbarButton class and add them to the toolbar with the AddButton or AddButtonAt methods. An item can be either a button or a divider. A button can work as either a pushbutton or a toggle button.

For best results, you should ensure that all your toolbar icons are the same size. Some platforms will size all icons to that of the icon on the first button in the toolbar.
You can only have a single toolbar on a Window.

Mouse events

Although DesktopToolbar inherits from DesktopUIControl, it has no mouse-related events. This is due to limitations of the operating system.

Sample Code

This example shows how to create a DesktopToolbar via code. It builds a small DesktopToolbar with Open and Save buttons. A DesktopToolbar object was added to a window. The pictures that are displayed by the two buttons were added to the project.

The window has the following properties:

SaveButton As DesktopToolbarButton
OpenButton As DesktopToolbarButton

The following code is in the Opening event of the DesktopToolbar instance in the window.

SaveButton = New DesktopToolbarButton
OpenButton = New DesktopToolbarButton

SaveButton.Caption = "Save" // Caption appears below the Icon
SaveButton.Name = "Save"
SaveButton.icon = SaveButtonImage // image added to the project

OpenButton.Caption = "Open" // Caption appears below the Icon
OpenButton.Name = "Open"
OpenButton.Icon = OpenButtonImage // image added to the project
SaveButton.ButtonStyle = DesktopToolbarButton.ButtonStyles.PushButton
OpenButton.ButtonStyle = DesktopToolbarButton.ButtonStyles.PushButton

// add to the Toolbar

The following code is in the Pressed event of the DesktopToolbar in the window:

Sub Pressed(item As DesktopToolItem)
Select Case item.Name
Case "Open"
MessageBox("You clicked the Open Button.")
Case "Save"
MessageBox("You clicked the Save Button.")
End Select
End Sub

See Also

DesktopToolbarButton, DesktopToolbarItem classes.