[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'ComCtrls' (#lcl)

TToolButton

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TToolButton is a button control in a TToolBar object.

Declaration

Source position: comctrls.pp line 2011

type TToolButton = class(TGraphicControl) end;

protected

Const

  cDefSeparatorWidth = 8

  cDefDividerWidth = 5

  cDefButtonDropDecArrowWidth = 2

  FToolBar: TToolBar;

  

FToolBar - local variable indicating in which toolbar this button lives

  class procedure WSRegisterClass; override;

  

Registers this component class with the current WidgetSet.

  procedure CopyPropertiesFromMenuItem();

  

CopyPropertiesFromMenuItem - method for copying the properties of the corresponding Menu Item, to ensure that ToolButton and MenuItem produce the same behaviour

  function GetActionLinkClass; override;

  

GetActionLinkClass - returns the Class of the ActionLink for this ToolButton

  procedure ActionChange(); override;

  

ActionChange - a method for changing the action associated with the Button

  procedure AssignTo(); override;

  

AssignTo calls inherited method: if the destination is of correct type, copies ImageIindex to destination and sets it Checked

  procedure BeginUpdate; virtual;

  

BeginUpdate - start the update process

  procedure EndUpdate; virtual;

  

EndUpdate - finish the update process

  procedure MouseMove(); override;

  

Handler for MouseMove events.

  procedure MouseDown(); override;

  

Handler for MouseDown events.

  procedure MouseUp(); override;

  

Invokes the OnMouseUp handler.

  procedure MouseEnter; override;

  

Invokes the OnMouseEnter handler.

  procedure MouseLeave; override;

  

Invokes the OnMouseLeave handler.

  procedure Notification(); override;

  

  procedure Paint; override;

  

Override this method with your own painting code.

  procedure TextChanged; override;

  

Handles changes of the Text property.

  procedure CalculatePreferredSize(); override;

  

Override this method to return the preferred height and width.

  class function GetControlClassDefaultSize; override;

  

GetControlClassDefaultSize returns its own defaults, overriding inherited values

  procedure Loaded; override;

  procedure RefreshControl; virtual;

  

RefreshControl - refreshes the drawing of the tool in case changes have been made

  procedure SetToolBar();

  

SetToolBar - records the existence of a new toolbar

  procedure UpdateControl; virtual;

  

UpdateControl - brings the control up to date

  function GetButtonDrawDetail; virtual;

  

GetButtonDrawDetail - find theme information for Windows XP inplementations

  procedure SetParent(); override;

  procedure UpdateVisibleToolbar;

  

UpdateVisibleToolbar - updates just the visible part of the toolbar

  function GroupAllUpAllowed;

  

GroupAllUpAllowed - returns True if all buttons in a group are allowed to ne 'Up'

  function DialogChar(); override;

  

Do something useful with accelerators etc.

  procedure SetAutoSize(); override;

  

  procedure RealSetText(); override;

public

  constructor Create(); override;

  

Create - constructor for TToolButton: calls inherited Create and sets initial bounds and style

  function CheckMenuDropdown; virtual;

  

CheckMenuDropdown - returns True if there is a checked dropdown menu

  procedure Click; override;

  

Invokes the OnClick and ActionLink.Execute handlers.

  procedure ArrowClick; virtual;

  

Invokes the OnArrowClick event handler

  procedure GetCurrentIcon(); virtual;

  

GetCurrentIcon - finds the icon for the current button

  procedure GetPreferredSize(); override;

  

Returns default/preferred height and width, for use in autosizing.

  property Index: Integer; [r]

  

Index - the sequence number of the current button in the list of buttons

  function PointInArrow();

published

  property Action: TBasicAction;

  

The Action associated with this control.

  property AllowAllUp: Boolean; [rw]

  

AllowAllUp - if True, all buttons are allowed to be 'Up' at the same time. Default False

  property AutoSize: Boolean;

  

Allows to automatically adjust the size of the control, according to its content.

  property Caption: TCaption;

  

The text describing the control to the user.

  property Down: Boolean; [rws]

  

Is this button Down (i.e. has it been selected)? Default false

  property DragCursor: TCursor;

  

The cursor shape shown while the control is dragged.

  property DragKind: TDragKind;

  

The operation when the control is dragged - Drag or Dock.

  property DragMode: TDragMode;

  

Allows the user to drag the control.

  property DropdownMenu: TPopupMenu; [rw]

  

A DropDownMenu that appears when this button is selected

  property Enabled: Boolean;

  

Determines whether the control reacts on mouse or keyboard input.

  property Grouped: Boolean; [rw]

  

Is this button a member of a group? Default false

  property Height: Integer; [s]

  

The vertical size of the control.

  property ImageIndex: TImageIndex; [rws]

  

ImageIndex - the index value of the image from the imagelist to be used with this button

  property Indeterminate: Boolean; [rw]

  

Indeterminate - if True, this button is in an unspecified state. Default False

  property Marked: Boolean; [rw]

  

Is this button Marked (i.e. has it been selected)? Default false

  property MenuItem: TMenuItem; [rw]

  

The item on the Main Menu with which this tool button is associated

  property OnArrowClick: TNotifyEvent; [rw]

  

Executed when user clicked the arrow part for Style=tbsDropDown.

  property OnClick: TNotifyEvent;

  

Notification handler for mouse clicks.

  property OnContextPopup: TContextPopupEvent;

  

Invoked when a context-sensitive pop-up menu is requested.

  property OnDragDrop: TDragDropEvent;

  

This handler determines the action on an drop onto this control, in a drag-drop operation.

  property OnDragOver: TDragOverEvent;

  

Event handler for a control being dragged over this control.

  property OnEndDock: TEndDragEvent;

  

Notification handler for the end of a docking operation.

  property OnEndDrag: TEndDragEvent;

  

Notification handler for the end of a dragging operation.

  property OnMouseDown: TMouseEvent;

  

Event handler for mouse button going down.

  property OnMouseEnter: TNotifyEvent;

  property OnMouseLeave: TNotifyEvent;

  property OnMouseMove: TMouseMoveEvent;

  

Event handler for mouse movement within the control.

  property OnMouseUp: TMouseEvent;

  

Event handler for mouse button going up.

  property OnMouseWheel: TMouseWheelEvent;

  property OnMouseWheelDown: TMouseWheelUpDownEvent;

  property OnMouseWheelUp: TMouseWheelUpDownEvent;

  property OnStartDock: TStartDockEvent;

  

Event handler for the start of a docking operation.

  property OnStartDrag: TStartDragEvent;

  

Event handler for the start of a dragging operation.

  property ParentShowHint: Boolean;

  

If true, the value of ShowHint for the control will be the same as the one from the Parent. Default is true.

  property PopupMenu: TPopupMenu;

  

A context-sensitive menu that pops up when the right mouse button is clicked over this control

  property ShowCaption: Boolean; [rw]

  

Show/Hide caption

  property ShowHint: Boolean;

  

Enables the Hint display.

  property Style: TToolButtonStyle; [rw]

  

Determines the style of the tool button.

  property Visible: Boolean;

  

Allows to show or hide the control, and all of its children.

  property Width: Integer; [s]

  

The horizontal extent of the control.

  property Wrap: Boolean; [rw]

  

Has this button been wrapped to the next row?

Inheritance

TToolButton

  

TToolButton is a button control in a TToolBar object.

|

TGraphicControl

  

TGraphicControl is the base class for all lightweight controls.

|

TControl

  

The base class for visible controls.

|

TLCLComponent

  

The base class for LCL components associated with widgets.

|

TComponent

?

TObject

Description

Use TToolButton to implement buttons on a toolbar. While other controls (including TButton and TSpeedButton) can be placed on toolbars, TToolButton utilizes special toolbar features to simplify the configuration of buttons and offers added display options such as pop-up borders and transparency.

To place tool buttons on a toolbar at design time, select the toolbar, right-click, and choose New Button.

See also

TToolBar

TButton

  

A push button control.

TSpeedButton

  

A Button used to represent states (checked or not, etc)

HowToUseStdCtrls

  

How to use StdCtrls, ComCtrls or ExtCtrls

Example

{ 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;
The latest version of this document can be found at lazarus-ccr.sourceforge.net.