RAD Studio VCL Reference
|
Determines the style of the tool button.
property Style: TToolButtonStyle;
__property TToolButtonStyle Style;
These are the possible values of Style:
Value |
Meaning |
tbsButton |
The button appears and functions like a normal speed button. |
tbsCheck |
Clicking the button toggles the Down property. Once selected, the button remains selected until clicked again. |
tbsDropDown |
The button displays a downward-pointing arrow (suitable for accessing a drop-down menu). |
tbsSeparator |
The button appears as an empty space on the toolbar (used to separate other controls). |
tbsDivider |
The button appears as a vertical line on the toolbar (used to separate other controls). |
tbsTextButton |
The button appears as text only. |
C++ Examples:
/* This example creates a ToolBar and adds ToolButtons to it. Include ComCtlrs in the uses clause. */ #include <comctrls.hpp> #include <memory> void AddButtons(TToolBar *toolBar, TStringList *captions) { for (int i = 0; i < captions->Count; i++) { TToolButton *button = new TToolButton(toolBar); // The owner (toolBar) will clean this up. button->Parent = toolBar; button->Caption = captions->Strings[i]; if (button->Caption == "|") button->Style = tbsSeparator; else button->Style = tbsButton; } } TToolBar *myToolBar; void __fastcall TForm1::FormCreate(TObject *Sender) { myToolBar = new TToolBar(this); // The owner (this) will clean this up. myToolBar->Parent = this; // TStringList *captions = new TStringList(); std::auto_ptr<TStringList> captions(new TStringList()); captions->Add("New"); captions->Add("Save"); captions->Add("|"); captions->Add("Cut"); captions->Add("Copy"); captions->Add("Paste"); AddButtons(myToolBar, captions.get()); // delete captions; myToolBar->ShowCaptions = True; myToolBar->Height = 40; }
Delphi Examples:
{ This example creates a ToolBar and adds ToolButtons to it. Include ComCtlrs in the uses clause. } procedure AddButtons(ToolBar: TToolBar; Const ButtonCaptions: array of String); var I: Integer; begin for I := 0 to High(ButtonCaptions) do begin with TToolButton.Create(ToolBar) do begin Parent := ToolBar; Caption := ButtonCaptions[I]; if (ButtonCaptions[I] = '|') then Style := tbsSeparator else Style := tbsButton; end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin ToolBar1 := TToolBar.Create(Self); ToolBar1.Parent := Self; AddButtons(ToolBar1, ['New', 'Save', '|', 'Cut', 'Copy', 'Paste']); ToolBar1.ShowCaptions := True; ToolBar1.Height := 40; end; procedure TForm1.FormDestroy(Sender: TObject); var I: Integer; begin for I := ToolBar1.ButtonCount - 1 downto 0 do ToolBar1.Buttons[I].Free; ToolBar1.Free; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|