image$ - A bitmap image file
x,y,width,height - Initial shape of the toolbar group - A group gadget handle |
CreateToolBar creates a toolbar gadget and returns a handle to it.
A toolbar is a horizontal strip of small buttons which the user can click. The image parameter specifies a bitmap file that contains the images for the toolbar's buttons. These images should be exactly square, and packed horizontally across the bitmap. The number of buttons is automatically determined by dividing the image width by its height. The very top left pixel color of the image determines the transparent color of the toolbar. Toolbars generate a gadget action event when the user clicks on a toolbar button. When a gadget action event is received, the EventData function can be used to determine the actual button clicked, with 0 indicating the left most button, 1 the next button and so on. It is also possible to add special separator items to a toolbar. Separator items are small gaps in the toolbar that visual group toolbar buttons into separate groups. To do this, simply insert a blank button icon (an icon with the same dimensions as a normal icon, but with all pixels equal to the transparent color) into your toolbar image anywhere you would like a separator to appear. See also: SetToolBarTips, EnableToolBarItem, DisableToolBarItem. |
; Example provided by Mag, added to documentation by Mark Tiffany
; get bitmap icon from the Blitz directory appdir$=SystemProperty("appdir") blitzdir$=Left(appdir,Len(appdir)-5) BMP$=blitzdir$+"\cfg\dbg_toolbar.bmp" Notify "We will use this bitmap for our ToolBar: "+Chr$(13)+BMP$ ; create a window to put the toolbar in WinHandle=CreateWindow("Test CreateToolbar",0,0,400,200) ; and create the toolbar toolHandle=CreateToolBar(BMP$,0,0,0,0,WinHandle) ; and now a loop to demonstrate it in action Repeat event=WaitEvent() If event=$803 Then End ; exit when we receive a Window Close event If event=$401 Then ; Button action event. EventData contains the toolbar button hit. ; Note that if we had more than just the toolbar on the form, we would check EventSource too If EventData()=0 Then Notify "Red Light selected" If EventData()=1 Then Notify "Green Light selected" If EventData()=2 Then Notify "Step Next selected" If EventData()=3 Then Notify "Step Into selected" If EventData()=4 Then Notify "Step Over selected" If EventData()=5 Then Notify "Boom selected" End If Forever End |