Class: cToolbarButton
Properties | Events | Methods | Index of Classes
Each instance represents a single button of a toolbar
Hierarchy
cObject > cToolbarButton
Show full hierarchy and direct subclasses
- cObject
- cToolbarButton
Library: Windows Application Class Library
Package: cToolbarButton.pkg
Description
This class is obsolete. Toolbars are now created using the cCJToolbar class.
As of revision 12.1, DataFlex includes full support for Codejock Software's COM Xtreme CommandBars package for creating menus, toolbars and statusbars. See Using Menus, Toolbars and Statusbars for more information.
Each instance of a cToolbarButton class represents a single button of a toolbar. You embed them within an instance of the cToolbar to provide a quick way to access functionality of the program.
Sample
Object oToolBar is a cToolBar
Object oImages is a cImageList
Set piMaxImages To 4
Procedure OnCreate
Integer iVoid
Get AddTransparentImage "Customer.bmp" clFuchsia To iVoid
Get AddTransparentImage "Cut16.bmp" clFuchsia To iVoid
Get AddTransparentImage "Copy16.bmp" clFuchsia To iVoid
Get AddTransparentImage "Paste16.bmp" clFuchsia To iVoid
End_Procedure
End_Object
Set phoImageList To (oImages(self))
Object oCustomer is a cToolbarButton
Set psTooltip To 'Customer View'
Set psStatusHelp To 'Activate the Customer View'
Set piImage To 0
Procedure OnClick
Send DoShowCustomer
End_Procedure
End_Object
Object oSeparator is a cToolbarButton
Set peStyle To bsSeparator
End_Object
Object oCut is a cToolbarButton
Set psTooltip To 'Cut'
Set psStatusHelp To 'Cuts the selection to the Clipboard'
Set piImage To 1
Procedure OnClick
Send DoSendToFocus msg_cut
End_Procedure
End_Object
Object oCopy is a cToolbarButton
Set psTooltip To 'Copy'
Set psStatusHelp To 'Copies the selection to the Clipboard'
Set piImage To 2
Procedure OnClick
Send DoSendToFocus msg_copy
End_Procedure
End_Object
Object oPaste is a cToolbarButton
Set psTooltip To 'Paste'
Set psStatusHelp To 'Inserts Clipboard contents'
Set piImage To 3
Procedure OnClick
Send DoSendToFocus msg_paste
End_Procedure
End_Object
End_Object // oToolbar
Shared Handlers
The buttons allow you to use a shared-handler. For example, rather than handling the OnClick event within each button, you could write a single handler at the toolbar that would receive the OnClick events for several buttons. To do this, set this property to the message-handle of shared handler. When this happens, the button will automatically pass the object-handle of the button to the shared handler as the first parameter. The shared handler must be in the delegation path of the button.
A frequent use of shared-handlers is when the buttons are created dynamically and there is no local object definition to handle the event in.
This sample shows two buttons using the same handler:
Object oToolbar is a cToolBar
Procedure OnClickShared Integer hoButton
Showln "OnClick happened in " (Name(hoButton))
End_Procedure
Object oButton1 is a cToolbarButton
Set phmOnClick To msg_OnClickShared
End_Object
Object oButton2 is a cToolbarButton
Set phmOnClick To msg_OnClickShared
End_Object
End_Object