Sign in Join
FPDoc Onlineexperiment

TToolButton class

In unit ComCtrls

TToolButton is a button control used in a TToolBar object.

Declaration

pascal
TToolButton = class(TGraphicControl)

Inheritance

  1. TToolButton
  2. TGraphicControl
  3. TControl
  4. TLCLComponent
  5. TComponent
  6. TPersistent
  7. 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 edge borders and transparency.

To place tool buttons on a toolbar at design time, select the toolbar, right-click, and choose New 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;

Properties

IndexpublicIndex- is the sequence number for the button in ButtonList.
ActionpublishedThe Action associated with the control.
AllowAllUppublishedIndicates if all buttons in a group can have their Down property set to False.
AutoSizepublishedAllows the control to grow to the size for its content.
CaptionpublishedThe text displayed for the control.
DownpublishedIndicates whether the button is in the "Down" state, i. e. has it been selected or clicked.
DragCursorpublishedThe cursor shape shown during a drag operation.
DragKindpublishedIndicates the action performed for a drag operation: drag-and-drop or drag-and-dock.
DragModepublishedDetermines how a drag operation is started for the control.
DropdownMenupublishedThe drop-down menu displayed when the button is pressed.
EnabledpublishedDetermines whether the button can respond to click events, and how it is displayed.
GroupedpublishedIndicates if the tool button is a member of a group. The default value is False.
HeightpublishedContains the height for the control in pixels.
ImageIndexpublishedOrdinal position in an image list for the icon displayed on the tool button.
IndeterminatepublishedIndicates if the tool button is in an undetermined state.
MarkedpublishedIndicates if the tool button is marked.
MenuItempublishedContains a menu item associated with the tool button.
ParentShowHintpublishedIf True, the value of ShowHint for the control will be the same as the one from the Parent. Default is True.
PopupMenupublishedA context-sensitive menu that pops up when the right mouse button is clicked over this control.
ShowCaptionpublishedIndicates whether the Caption text is displayed on the tool button.
ShowHintpublishedEnables Hint display for the control.
StylepublishedDetermines the display style for the tool button.
VisiblepublishedAllows the control, and all of its children, to be displayed or hidden.
WidthpublishedThe horizontal size for the control.
WrappublishedIndicates whether the tool button is forced onto the next row on the parent tool bar.

Methods

WSRegisterClassprotectedRegisters this component class with the current WidgetSet.
CopyPropertiesFromMenuItemprotectedCopies properties from the specified menu item.
GetActionLinkClassprotectedGets the class type for the ActionLink in the tool button.
ActionChangeprotectedImplements the handler signalled when the Action for the tool button is changed.
AssignToprotectedImplements object persistence used to assign properties from the class instance to another persistent object.
BeginUpdateprotectedStarts an update process for the tool button.
EndUpdateprotectedEnds an update process for the tool button.
MouseMoveprotectedDetects whether the mouse is hovered over the drop-down indicator for the tool button.
MouseDownprotectedHandles mouse click events for the tool button.
MouseUpprotectedHandles mouse up events for the tool button.
MouseEnterprotectedHandles a message sent when the mouse enters a control.
MouseLeaveprotectedHandles a message sent when the mouse leaves a control.
NotificationprotectedHandles the notification sent when a component is added to or removed from the control.
PaintprotectedDraws the tool bar button to the Canvas for the control.
TextChangedprotectedPerforms actions needed when the caption text for the tool button has been changed.
CalculatePreferredSizeprotectedCalculates the preferred dimensions for new instances of the control.
GetControlClassDefaultSizeprotectedGetControlClassDefaultSize returns its own defaults, overriding inherited values.
LoadedprotectedPerforms actions needed when LCL component streaming has been completed.
RefreshControlprotectedRefreshes the button control by updating it parent tool bar.
SetToolBarprotectedSets the value for the internal member with the TToolBar instance for the button.
UpdateControlprotectedCauses the tool bar to adjust the size and position for its Buttons and Controls.
GetButtonDrawDetailprotectedGets the Theme Element Details used for the tool button.
SetParentprotectedSets the value for the Parent property.
UpdateVisibleToolbarprotectedCalls the corresponding method in the tool bar for the button.
GroupAllUpAllowedprotectedIndicates if all buttons in the group are allowed to be in the 'Up' position.
DialogCharprotectedClicks the button when the message contains the accelerator key for the button control.
SetAutoSizeprotectedSets the value the AutoSize property and adjusts the control size when needed.
RealSetTextprotectedSets the value for the Caption property.
CreatepublicConstructor for the class instance.
CheckMenuDropdownpublicChecks for and executes a drop-down menu for the tool button.
ClickpublicSignals OnClick and/or executes the ActionLink when the control has been clicked.
ArrowClickpublicSignals the OnArrowClick event handler for the tool button.
GetCurrentIconpublicGets the image list, index, and drawing effect for the icon on the tool button.
GetPreferredSizepublicReturns default/preferred height and width, for use in auto-sizing.
PointInArrowpublicIndicates if the specified position is within the bounds for the arrow drawn on a drop-down button.

Events

OnArrowClickpublishedEvent handler signalled when the drop-down indicator for a tool button is clicked.
OnClickpublishedEvent handler signalled when the tool button has been clicked.
OnContextPopuppublishedInvoked when a context-sensitive pop-up menu is requested.
OnDragDroppublishedEvent handler signalled when an object is dropped onto the control.
OnDragOverpublishedEvent handler signalled when a control is dragged over the control instance.
OnEndDockpublishedEvent handler signalled for the end of a drag-dock operation.
OnEndDragpublishedEvent handler signalled for the end of a drag-drop operation.
OnMouseDownpublishedEvent handler signalled when a mouse down event is handled for the control.
OnMouseEnterpublishedEvent handler signalled when the mouse pointer has entered the control.
OnMouseLeavepublishedEvent handler signalled when the mouse pointer has left the control.
OnMouseMovepublishedEvent handler signalled when the mouse pointer is moved in the control.
OnMouseUppublishedEvent handler signalled when a mouse up event is handled for the control.
OnMouseWheelpublishedEvent handler for mouse wheel turned.
OnMouseWheelDownpublishedEvent handler signalled for a downward movement of the mouse wheel.
OnMouseWheelUppublishedEvent handler signalled for an upward movement of the mouse wheel.
OnStartDockpublishedEvent handler for the start of a docking operation.
OnStartDragpublishedEvent handler signalled for the start of a dragging operation.

Fields

FToolBarprotectedMember variable with the tool bar where the button is used.

Types and constants

cDefSeparatorWidthprotectedDefault width for tool buttons using the separator style.
cDefDividerWidthprotectedDefault width for tool buttons using the divider style.
cDefButtonDropDecArrowWidthprotectedDefault width for the drop-down indicator in tool buttons.
cHorIconTextDistprotectedDefault number of pixels between the icon and the text on the tool button. It is used when the List property in the parent tool bar is enabled, and contains the number of pixels (prior to scaling) between the right edge of the icon (when assigned) and the caption text. It is included in the size val
cVertIconTextDistprotected

Inherited

From TGraphicControl (7)

Canvas CMCursorChanged Destroy DoOnChangeBounds DoOnParentHandleDestruction FontChanged OnPaint

From TControl (363)

AccessibleDescription AccessibleName AccessibleRole AccessibleValue ActionLink ActiveDefaultControlChanged AddHandler AddHandlerOnBeforeDestruction AddHandlerOnChangeBounds AddHandlerOnEnabledChanged AddHandlerOnEnabledChanging AddHandlerOnKeyDown AddHandlerOnMouseWheel AddHandlerOnResize AddHandlerOnVisibleChanged AddHandlerOnVisibleChanging AdjustSize Align AnchorAsAlign AnchorClient AnchoredControlCount AnchoredControls AnchorHorizontalCenterTo AnchorParallel Anchors AnchorSame AnchorSide AnchorSideBottom AnchorSideChanged AnchorSideLeft AnchorSideRight AnchorSideTop AnchorToCompanion AnchorToNeighbour AnchorVerticalCenterTo AutoAdjustLayout AutoSizeDelayed AutoSizeDelayedHandle AutoSizeDelayedReport AutoSizePhases AutoSizing AutoSizingAll AutoSizingLockCount BaseBounds BaseParentClientSize BeforeDestruction BeforeDragStart BeginAutoDrag BeginAutoSizing BeginDrag BiDiMode BorderSpacing BoundsChanged BoundsRect BoundsRectForNewParent BringToFront CalculateDockSizes CanAutoSize CanTab CaptureChanged CaptureMouseButtons ChangeBounds Changed ChangeScale CheckChildClassAllowed CheckNewParent CheckOnChangeBounds ChildClassAllowed ClientHeight ClientOrigin ClientRect ClientToParent ClientToScreen ClientWidth CMBiDiModeChanged CMChanged CMEnabledChanged CMHintShow CMHitTest CMMouseEnter CMMouseLeave CMParentBiDiModeChanged CMParentColorChanged CMParentFontChanged CMParentShowHintChanged CMSysFontChanged CMTextChanged CMVisibleChanged CNPreferredSizeChanged Color ColorIsStored ConstrainedResize Constraints ControlFontClass ControlOrigin ControlState ControlStyle ControlToScreen CreateAccessibleObject CreateControlBorderSpacing CreateFloatingDockSite Cursor DblClick DefineProperties DesktopFont DisableAutoSizing DoAllAutoSize DoAutoAdjustLayout DoAutoSize DoBorderSpacingChange DoCallKeyEventHandler DoCallMouseWheelEventHandler DoCallNotifyHandler Dock Docked DockOrientation DockTrackNoTarget DoConstraintsChange DoContextPopup DoDock DoDragMsg DoEndDock DoEndDrag DoFixDesignFontPPI DoFloatMsg DoMouseDown DoMouseUp DoMouseWheel DoMouseWheelDown DoMouseWheelHorz DoMouseWheelLeft DoMouseWheelRight DoMouseWheelUp DoOnResize DoOnShowHint DoScaleFontPPI DoSetBounds DoStartDock DoStartDrag DragCanceled DragDrop Dragging DragOver EditingDone EnableAutoSizing EnabledChanged EnabledChanging EndAutoSizing EndDrag ExecuteCancelAction ExecuteDefaultAction FindSubComponent FixDesignFontsPPI Floating FloatingDockSiteClass Font ForeignAnchorSideChanged FormEndUpdated FormIsUpdating GetAccessibleObject GetAction GetAnchorsDependingOnParent GetCachedText GetCanvasScaleFactor GetChildAccessibleObjectAtPos GetChildrenRect GetClientOrigin GetClientRect GetClientScrollOffset GetColorResolvingParent GetControlOrigin GetCursor GetDefaultColor GetDefaultDockCaption GetDefaultHeight GetDefaultWidth GetDeviceContext GetDockEdge GetDragImages GetEnabled GetFloating GetFloatingDockSiteClass GetLogicalClientRect GetMouseCapture GetMousePosFromMessage GetPalette GetParentBackground GetParentComponent GetPopupMenu GetRGBColorResolvingParent GetScrolledClientRect GetSelectedChildAccessibleObject GetSidePosition GetTextBuf GetTextLen GetTopParent HandleObjectShouldBeVisible HasHelp HasParent HeightIsAnchored HelpContext HelpKeyword HelpType Hide Hint HostDockSite InitiateAction Invalidate InvalidateControl InvalidatePreferredSize IsAParentAligning IsBorderSpacingInnerBorderStored IsCaptionStored IsClientHeightStored IsClientWidthStored IsControl IsControlVisible IsEnabled IsParentColor IsParentFont IsParentOf IsProcessingPaintMsg IsRightToLeft IsVisible Left LMCaptureChanged LoadedAll LRDockWidth ManualDock ManualFloat MouseCapture MouseInClient OnChangeBounds OnConstrainedResize OnDblClick OnEditingDone OnMouseWheelHorz OnMouseWheelLeft OnMouseWheelRight OnQuadClick OnResize OnShowHint OnTripleClick Parent ParentBackground ParentBiDiMode ParentColor ParentDestroyingHandle ParentFont ParentFontChanged ParentFormHandleInitialized ParentHandlesAllocated ParentToClient Perform PositionDockRect QuadClick ReadBounds ReadState RealGetText Refresh RemoveAllHandlersOfObject RemoveHandler RemoveHandlerOnBeforeDestruction RemoveHandlerOnChangeBounds RemoveHandlerOnEnabledChanged RemoveHandlerOnEnabledChanging RemoveHandlerOnKeyDown RemoveHandlerOnMouseWheel RemoveHandlerOnResize RemoveHandlerOnVisibleChanged RemoveHandlerOnVisibleChanging Repaint ReplaceDockedControl RequestAlign Resize Scale96ToFont Scale96ToForm Scale96ToScreen ScaleConstraints ScaleDesignToForm ScaleFontsPPI ScaleFontTo96 ScaleFontToScreen ScaleFormTo96 ScaleFormToDesign ScaleScreenTo96 ScaleScreenToFont ScreenToClient ScreenToControl SendMoveSizeMessages SendToBack SessionProperties SetAction SetAlign SetAnchors SetBiDiMode SetBounds SetBoundsKeepBase SetColor SetCursor SetDragMode SetEnabled SetHint SetInitialBounds SetName SetParentBackground SetParentBiDiMode SetParentComponent SetTempCursor SetTextBuf SetVisible SetZOrder ShouldAutoAdjust Show ShowHelp TBDockHeight Text Top TripleClick UndockHeight UndockWidth Update UpdateAnchorRules UpdateBaseBounds UpdateMouseCursor UpdateRolesForForm UseRightToLeftAlignment UseRightToLeftReading UseRightToLeftScrollBar VisibleChanged VisibleChanging WidthIsAnchored WindowProc WMCancelMode WMContextMenu WMLButtonDBLCLK WMLButtonDown WMLButtonQuadCLK WMLButtonTripleCLK WMLButtonUp WMMButtonDBLCLK WMMButtonDown WMMButtonQuadCLK WMMButtonTripleCLK WMMButtonUp WMMouseHWheel WMMouseMove WMMouseWheel WMMove WMRButtonDBLCLK WMRButtonDown WMRButtonQuadCLK WMRButtonTripleCLK WMRButtonUp WMSize WMWindowPosChanged WMXButtonDBLCLK WMXButtonDown WMXButtonQuadCLK WMXButtonTripleCLK WMXButtonUp WndProc WriteLayoutDebugReport

From TLCLComponent (6)

DecLCLRefCount GetWSComponentClass IncLCLRefCount LCLRefCount NewInstance WidgetSetClass

From TComponent (65)

_AddRef _Release CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetChildren GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetTypeInfo GetTypeInfoCount iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState

From TPersistent (4)

Assign FPOAttachObserver FPODetachObserver FPONotifyObservers

From TObject (36)

AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName

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