Sign in Join
FPDoc Onlineexperiment

TToolButton.Style property

Member of TToolButtonpublishedIn unit ComCtrls

Determines the display style for the tool button.

Declaration

pascal
property Style: TToolButtonStyle read FStyle write SetStyle default tbsButton;

Description

Style is a TToolButtonStyle property which controls the visual display style and behavior for the button on its tool bar. Values allowed in the property include:

  • tbsButton
  • tbsCheck
  • tbsDropDown
  • tbsSeparator
  • tbsDivider
  • tbsButtonDrop

The default value for the property is tbsButton. This causes the button to be displayed using the behavior for a TSpeedButton class instance. In other words, it is a momentary button which performs its Click method when the left mouse button is clicked and released.

See TToolButtonStyle for more information about the values for the property.

Changing the value for the property causes the Width, Height, and preferred size for the button to be recalculated. If the button is Visible, the visible area on the Parent tool bar is redisplayed by calling UpdateVisibleToolbar.

Use Grouped and AllowAllUp to control button behavior for adjacent grouped buttons on the tool bar using the checked style.

Use the Caption and ShowCaption properties to control the text displayed on the button.

See also

Example: ttoolbutton.pas

pascal
{ To use this example, create a new application and add the example code
  to the unit. Remember to add the ComCtls unit 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;
      AutoSize := True;
    end;
  end;
end;


procedure TForm1.FormCreate(Sender: TObject);
var
  ToolBar: TToolBar;
begin
  ToolBar := TToolBar.Create(Self);
  ToolBar.Parent := Self;
  ShowMessage(IntToStr(ToolBar.ButtonCount));
  AddButtons(ToolBar, ['New', 'Save', '|', 'Cut', 'Copy', 'Paste']);
  ToolBar.ShowCaptions := True;
  ToolBar.Height := 40;
  ToolBar.ButtonWidth := 75;
  ShowMessage(IntToStr(ToolBar.ButtonCount));
end;

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.