TPanel | Simple, but lacks automatic wrapping | |
TToolBar | Easy to use, good suport for actions - I recommend using this | |
TControlBar | Allows multiple toolbars - but has problems | |
TCoolBar | Allows multiple toolbars - but has problems |
TPanel
Both TBitBtn and TSpeedButton have a glyph property that is automatically set when the Action property is set (assuming that an ImageList is associated with the ActionList).
Though this is the most straight forward way to produce a toolbar, it does not perform automatic wrapping and it requires extra space because it saves each image (glyph) twice - in the ImageList and with its button.
TToolBar
Set Flat to true to remove the "raised" borders around the buttons.
Docking with Several Toolbars
You should also set these ToolBar properties
Problem with Wrapped Toolbars in Design Mode
TToolButton
You will probably want to set the Style property.
Style | |
---|---|
tbsButton | This is the default - just click the button to activate the action. |
tbsCheck | Click once to set the button, click again to release it. Set Grouped to true if you want to have only one of a group of adjacent buttons to be down at a given time. |
tbsDropDown | This shows a dropdown arrow. The menu attached to MenuItem is displayed when the arrow is pressed. Since your form can have multiple TMainMenu components, attach one to the form (it will be displayed as the menu), and attach a top level menu from the second TMainMenu component to the button. (The PopupMenu is displayed when the button is right clicked.) |
tbsSeparator | This is just a blank space between buttons. When the toolbar automatically wraps to another line, it breaks on separators. |
tbsDivider | This displays a vertical line - used to group buttons. You should not use these if the toolbar is allowed to wrap. (It looks bad.) |
TPageScroller
Well, it doesn't work.
Some functionality is available if the toolbar's Align property
is set to alNone,
the Wrapable property is set to False,
and the toolbar is moved to the right.
But in my testcase, there were still several buttons that were never displayed.
(Tested with Delphi 5 on Windows 98)
TControlBar
I was able to break this by placing 2 toolbars on the same line (in run mode).
First, resize the form so that the right-most toolbar is shortened.
Then drag the right-most toolbar to the second line.
Now there is no way to get it back to its original size.
In addition, any buttons that are wrapped to the second line
disappear (ie, they are not available).
It is possible to inhibit this behaivor by
making the changes suggested in the first paragraph.
(Tested with Delphi 5 on Windows 98)
You should set TControlBar.AutoSize to True so that the ControlBar will automatically resize itself to be as small as possible.
The default RowSize property is too small, increase it from 26 to 30 so that the toolbar buttons will fit.
When the user drags the toolbar off the form, it is displayed in its own window. However, if the user then clicks the x in the title bar, the toolbar window closes and there is no way for the user to get it back. As a result, you should define a PopupMenu for the ControlBar that allows the user to turn the toolbars on and off. (See the Delphi IDE for an example.)
Set TControlBar.DragKind to dkDock and TControlBar.DragMode to dmAutomatic to allow the user to drag the ControlBar and all its toolbars off the form. You will need another TControlBar (or another component with DockSite set to true) if you want to be able to place it back in the form. (Do not set DockSite to true on the form itself. I don't like how that works)
In a ControlBar, the ToolBar's handle is two vertical bars and the cursor does not change when you point to it. This "appears" to be what the Delphi IDE uses.
If you also want to have a "menu" toolbar, search the net for TMenuBar. Alternatively, you can configure a toolbar to display a menu.
For more information on docking, see Delphi By Design.
TCoolBar
By default, DockSite is set to false. Change this if you want to let the user undock and dock toolbars.
The toolbar handle is a single vertical bar, the cursor changes when you point to the handle.
When testing, I was able to create a situation where one toolbar
wrapped on top of another. It was a complete and unusable mess.
(Tested with Delphi 5 on Windows 98)
Developer's Guide