TToolBar
Source: source/classes/toolbar.prg
Inherits from: TControl
TToolBar is a toolbar control that hosts bitmap buttons with optional tooltips, images, and modern visual styles. It provides a dockable strip of buttons typically placed at the top of a window. TToolBar supports flat and 3D button styles, image lists for button glyphs, and modern themes (2007/2010/2013/2015).
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nBtnWidth | Numeric | Width of each toolbar button |
nBtnHeight | Numeric | Height of each toolbar button |
aButtons | Array | Array of button definitions added to the toolbar |
oImageList | Object | Image list supplying button glyphs |
lTTBalloon | Logical | Enable balloon-style tooltips instead of standard |
l2007 | Logical | Office 2007-themed flat buttons |
l2010 | Logical | Office 2010-themed flat buttons |
l2013 | Logical | Office 2013-themed flat buttons |
l2015 | Logical | Office 2015-themed flat buttons |
Methods
| Method | Description |
|---|---|
New( oWnd, nBtnW, nBtnH, oImgLst, nClrT, nClrP, lPix, lDes, cMsg, lAdj, lTr, oFont, bClrG, l2007, l2010, l2013, l2015, nTop, nLeft, nW, nH, lNoB, lBlon ) | Create a new toolbar on the given window |
AddButton( bAction, cToolTip, cText, bWhen, cMsg ) | Add a button with action, tooltip, optional text |
AddMenu( bAction, cToolTip, cText, bWhen, cMsg, bMenu ) | Add a dropdown button that shows a popup menu |
AddSeparator() | Add a vertical separator between buttons |
DelButton( n ) | Remove a button at the given position |
SetChecked( n, l ) | Check or uncheck a toggle button |
IsChecked( n ) | Return .T. if the button at position n is checked |
Example: Toolbar with Three Buttons
#include "FiveWin.ch"
function Main()
local oWnd, oToolBar, oImgList
DEFINE WINDOW oWnd TITLE "TToolBar Demo" SIZE 600, 400
oImgList := TImageList():New( 24, 24 )
oToolBar := TToolBar():New( oWnd, 32, 32, oImgList, , , .T., , , , , , , .T. )
oToolBar:AddButton( { || MsgInfo( "New" ) }, "Create a new document", "New" )
oToolBar:AddButton( { || MsgInfo( "Open" ) }, "Open an existing file", "Open" )
oToolBar:AddSeparator()
oToolBar:AddButton( { || MsgInfo( "Save" ) }, "Save current document", "Save" )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TToolBar automatically creates child
TButtonobjects for eachAddButtoncall. ThenBtnWidthandnBtnHeightcontrol the size of all buttons uniformly. - Use
l2007,l2010,l2013, orl2015to apply modern flat-button themes. Only one theme flag should be .T. at a time. - When
lTTBalloonis .T., tooltips are rendered in the balloon style with rounded corners and a pointed tail. - Set the
oImageListto supply glyph images for buttons. Each button's image index corresponds to its position in the toolbar's internal button array. - The toolbar is typically docked at the top of the window using
oWnd:oTop := oToolBarafter creation.