TToolBar

Fonte: 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

DATATypeDescription
nBtnWidthNumericWidth of each toolbar button
nBtnHeightNumericHeight of each toolbar button
aButtonsArrayArray of button definitions added to the toolbar
oImageListObjectImage list supplying button glyphs
lTTBalloonLogicalEnable balloon-style tooltips instead of standard
l2007LogicalOffice 2007-themed flat buttons
l2010LogicalOffice 2010-themed flat buttons
l2013LogicalOffice 2013-themed flat buttons
l2015LogicalOffice 2015-themed flat buttons

Methods

MethodDescription
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

Veja Também