Overview
Previous  Next

The ToolBar control enhances the user GUI by adding support for a graphical bar.
There is a difference between the desktop ToolBar and the device ToolBar.
While on the desktop each ToolBar appears under the menu items, on the device the ToolBar uses the same space of the menu.
On the device the ToolBar will show right of the menu (if there is any room left).
The library includes two types of objects, ToolBar and ToolBarButton.
ToolBar is a container of ToolBarButtons.
A ToolBarButton can include a menu (by setting its style to stDropDownButton). The menu is a context menu which is created using the FormLib library.
A ToolBarButton shows one of the images that were added to the ToolBar.

Example:
'Add a ToolBar object named bar.
'Add three ToolBarButtons named btn1, btn2 and btn3.
'Add a ContextMenu (from the FormLib library) named menu.
'Change pic1.jpg and pic2.jpg to existing images.
Sub Globals

End Sub

Sub App_Start
      Form1.Show
      menu.New1 'Context menu for one of the buttons.
      bar.New1("form1")
      btn1.New1
      btn2.New1
      btn3.New1
      bar.AddImage1(AppPath & "\pic1.jpg")
      bar.AddImage1(AppPath & "\pic2.jpg")
      bar.AddToolBarButton(btn1.Value)
      bar.AddToolBarButton(btn2.Value)
      bar.AddToolBarButton(btn3.Value)
      btn1.Style = btn1.stToggleButton
      btn2.Style = btn1.stPushButton 'Default value
      btn3.Style = btn3.stDropDownButton
      btn1.ImageIndex = 0 'Pic1
      btn2.ImageIndex = 1 'Pic2
      btn3.ImageIndex = 1 'Pic2
      menu.AddItem("First Item")
      menu.AddItem("Second Item")
      btn3.Menu = menu.Value 'Adds the context menu to btn3.
End Sub

'Handles the ContextMenu click event.
Sub menu_Click
      msgbox(menu.SelectedText)     
End Sub

'Handles the ToolBar click event.
Sub bar_Click
      Select bar.SelectedButton
            Case 0
                  Msgbox ("First Button was clicked")
            Case 1
                  Msgbox ("Second Button was clicked")
            Case 2
                  Msgbox ("Third button was clicked")
      End Select
End Sub