The toolbar component (Ttoolbar) provides a way for users to access shortcut menus.
Buttions
Lists the tool buttons in the toolbar that hold a list of Ttoolbutton instances
Canvas
Use this property in the Oncustomdraw or Oncustomdrawitem event to draw on the toolbar.
Constraints
Specify the size limit for Ttoolbar
Customizable
Set this property to True to allow users to add, remove, and move toolbar buttons while the program is running. The user can press the SHIFT key to drag the button to a new location, or drag it away
Cusstiomizekeyname
Use this property to specify the location where the button configuration is saved when the current user first displays a customized dialog box for the toolbar
Cusstiomizevaluename
Use this property to specify the location where the button configuration name is saved when the current user first displays a customized dialog box for the toolbar
Disabledimages
This property contains an image list, and the ImageIndex property of each tool button determines the icon to display on the button.
Image
Provide an image list for Ttoolbar
Menu
Use this property to make the buttons on the toolbar correspond to items in the menu
Example drawing on a ttoolbar component with the Canvas property
Const arect:trect; var Defaultdraw:boolean); var bitmap:tbitmap;begin bitmap:= tbitmap.create; Bitmap. LoadFromFile ('C:\Documents and Settings\All Users\Documents\My Pictures\ example Picture \mm1.bmp ' ); ToolBar1.Canvas.StretchDraw (ARECT,BITMAP); Bitmap. Free;end;
Example 2: Make a transparent button effect
Const arect:trect; var Defaultdraw:boolean); var bitmap:tbitmap;begin bitmap:= tbitmap.create; Bitmap. LoadFromFile ('C:\Documents and Settings\All Users\Documents\My Pictures\ example Picture \mm1.bmp ' ); ToolBar1.Canvas.StretchDraw (ARECT,BITMAP); Bitmap. Free;end;procedure tform1.formcreate (sender:tobject); begin Toolbar1.showcaptions:= True; Toolbar1.flat:true; end;end.
Example 3 button onclick event instance
procedure Tform1.toolbutton1click (sender:tobject); Begin Case as Ttoolbutton ). Indexof0: Begin ShowMessage (' open program ' ); End; 1 : Begin ShowMessage (' Save program '); End; End;end;end.
Delphi Toolbar component (Ttoolbar)