TToolButton class
TToolButton is a button control used in a
TToolBar
object.Declaration
TToolButton = class(TGraphicControl)Inheritance
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
{ 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
Index | public | Index- is the sequence number for the button in ButtonList. |
Action | published | The Action associated with the control. |
AllowAllUp | published | Indicates if all buttons in a group can have their Down property set to False. |
AutoSize | published | Allows the control to grow to the size for its content. |
Caption | published | The text displayed for the control. |
Down | published | Indicates whether the button is in the "Down" state, i. e. has it been selected or clicked. |
DragCursor | published | The cursor shape shown during a drag operation. |
DragKind | published | Indicates the action performed for a drag operation: drag-and-drop or drag-and-dock. |
DragMode | published | Determines how a drag operation is started for the control. |
DropdownMenu | published | The drop-down menu displayed when the button is pressed. |
Enabled | published | Determines whether the button can respond to click events, and how it is displayed. |
Grouped | published | Indicates if the tool button is a member of a group. The default value is False. |
Height | published | Contains the height for the control in pixels. |
ImageIndex | published | Ordinal position in an image list for the icon displayed on the tool button. |
Indeterminate | published | Indicates if the tool button is in an undetermined state. |
Marked | published | Indicates if the tool button is marked. |
MenuItem | published | Contains a menu item associated with the tool button. |
ParentShowHint | published | If True, the value of ShowHint for the control will be the same as the one from the Parent. Default is True. |
PopupMenu | published | A context-sensitive menu that pops up when the right mouse button is clicked over this control. |
ShowCaption | published | Indicates whether the Caption text is displayed on the tool button. |
ShowHint | published | Enables Hint display for the control. |
Style | published | Determines the display style for the tool button. |
Visible | published | Allows the control, and all of its children, to be displayed or hidden. |
Width | published | The horizontal size for the control. |
Wrap | published | Indicates whether the tool button is forced onto the next row on the parent tool bar. |
Methods
WSRegisterClass | protected | Registers this component class with the current WidgetSet. |
CopyPropertiesFromMenuItem | protected | Copies properties from the specified menu item. |
GetActionLinkClass | protected | Gets the class type for the ActionLink in the tool button. |
ActionChange | protected | Implements the handler signalled when the Action for the tool button is changed. |
AssignTo | protected | Implements object persistence used to assign properties from the class instance to another persistent object. |
BeginUpdate | protected | Starts an update process for the tool button. |
EndUpdate | protected | Ends an update process for the tool button. |
MouseMove | protected | Detects whether the mouse is hovered over the drop-down indicator for the tool button. |
MouseDown | protected | Handles mouse click events for the tool button. |
MouseUp | protected | Handles mouse up events for the tool button. |
MouseEnter | protected | Handles a message sent when the mouse enters a control. |
MouseLeave | protected | Handles a message sent when the mouse leaves a control. |
Notification | protected | Handles the notification sent when a component is added to or removed from the control. |
Paint | protected | Draws the tool bar button to the Canvas for the control. |
TextChanged | protected | Performs actions needed when the caption text for the tool button has been changed. |
CalculatePreferredSize | protected | Calculates the preferred dimensions for new instances of the control. |
GetControlClassDefaultSize | protected | GetControlClassDefaultSize returns its own defaults, overriding inherited values. |
Loaded | protected | Performs actions needed when LCL component streaming has been completed. |
RefreshControl | protected | Refreshes the button control by updating it parent tool bar. |
SetToolBar | protected | Sets the value for the internal member with the TToolBar instance for the button. |
UpdateControl | protected | Causes the tool bar to adjust the size and position for its Buttons and Controls. |
GetButtonDrawDetail | protected | Gets the Theme Element Details used for the tool button. |
SetParent | protected | Sets the value for the Parent property. |
UpdateVisibleToolbar | protected | Calls the corresponding method in the tool bar for the button. |
GroupAllUpAllowed | protected | Indicates if all buttons in the group are allowed to be in the 'Up' position. |
DialogChar | protected | Clicks the button when the message contains the accelerator key for the button control. |
SetAutoSize | protected | Sets the value the AutoSize property and adjusts the control size when needed. |
RealSetText | protected | Sets the value for the Caption property. |
Create | public | Constructor for the class instance. |
CheckMenuDropdown | public | Checks for and executes a drop-down menu for the tool button. |
Click | public | Signals OnClick and/or executes the ActionLink when the control has been clicked. |
ArrowClick | public | Signals the OnArrowClick event handler for the tool button. |
GetCurrentIcon | public | Gets the image list, index, and drawing effect for the icon on the tool button. |
GetPreferredSize | public | Returns default/preferred height and width, for use in auto-sizing. |
PointInArrow | public | Indicates if the specified position is within the bounds for the arrow drawn on a drop-down button. |
Events
OnArrowClick | published | Event handler signalled when the drop-down indicator for a tool button is clicked. |
OnClick | published | Event handler signalled when the tool button has been clicked. |
OnContextPopup | published | Invoked when a context-sensitive pop-up menu is requested. |
OnDragDrop | published | Event handler signalled when an object is dropped onto the control. |
OnDragOver | published | Event handler signalled when a control is dragged over the control instance. |
OnEndDock | published | Event handler signalled for the end of a drag-dock operation. |
OnEndDrag | published | Event handler signalled for the end of a drag-drop operation. |
OnMouseDown | published | Event handler signalled when a mouse down event is handled for the control. |
OnMouseEnter | published | Event handler signalled when the mouse pointer has entered the control. |
OnMouseLeave | published | Event handler signalled when the mouse pointer has left the control. |
OnMouseMove | published | Event handler signalled when the mouse pointer is moved in the control. |
OnMouseUp | published | Event handler signalled when a mouse up event is handled for the control. |
OnMouseWheel | published | Event handler for mouse wheel turned. |
OnMouseWheelDown | published | Event handler signalled for a downward movement of the mouse wheel. |
OnMouseWheelUp | published | Event handler signalled for an upward movement of the mouse wheel. |
OnStartDock | published | Event handler for the start of a docking operation. |
OnStartDrag | published | Event handler signalled for the start of a dragging operation. |
Fields
FToolBar | protected | Member variable with the tool bar where the button is used. |
Types and constants
cDefSeparatorWidth | protected | Default width for tool buttons using the separator style. |
cDefDividerWidth | protected | Default width for tool buttons using the divider style. |
cDefButtonDropDecArrowWidth | protected | Default width for the drop-down indicator in tool buttons. |
cHorIconTextDist | protected | Default 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 |
cVertIconTextDist | protected |
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.
