HBasicControls: Buttons and Menus

HBasicControls overview
Build action areas, configure buttons, and display dialog titles or popup menus.

ThButtonsArea

A container control used to host a horizontal area of buttons, typically placed at the bottom of a dialog or form.
Designed to provide consistent layout, spacing, and alignment for standard actions like OK, Cancel, Next, or custom buttons.
Supports dynamic button arrangement, styling, visibility toggling, and flexible anchoring behaviors.
Built on TSYE_Control, allowing theme-aware rendering and FMX compatibility in the future.
Commonly used in wizards, confirmation dialogs, and configuration pages within SYE-based applications.
Members declared as ThBA_Foundation belong to the shared base class and can also be called on ThButtonsArea.

Button

Retrieves a button item by its internal name from the button area.
Used to access or modify a specific button's state, caption, or behavior.
Function ThBA_Foundation.Button(CONST ButtonName: String): ThButtonItem;

Parameters

  • ButtonName: String; The internal name of the button to retrieve.

Return Value

Returns the corresponding ThButtonItem, or nil if not found.

PostClick

Simulates a click on the specified button if the control is not in a busy state.
Used to trigger actions programmatically while respecting the user interaction lock.
Procedure ThBA_Foundation.PostClick(CONST ButtonName: String);

Parameters

  • ButtonName: String; The internal name of the button to click.

PostClick_Timer

Schedules a simulated button click after a specified delay in milliseconds.
Useful for auto-confirmations, timed dialogs, or guided UI sequences.
Procedure ThBA_Foundation.PostClick_Timer(CONST ButtonName: String; MilliSeconds: Integer);

Parameters

  • ButtonName: String; The name of the button to trigger.
  • MilliSeconds: Integer; Delay before click in milliseconds (valid range: 30–180000).

Post_Hotkey

Processes a hotkey event and dispatches it to a matching button if applicable.
Enables keyboard shortcut integration with the button area for enhanced accessibility.
Procedure ThBA_Foundation.Post_Hotkey(VAR Key: Word);

Parameters

  • Key: Word; The key code representing the hotkey to evaluate and route.

Set_All_Buttons_Enabled

Changes ordinary, non-script buttons. Pass AllBtns=True to include spacers and dynamic script buttons.
Procedure ThBA_Foundation.Set_All_Buttons_Enabled(CONST New: Boolean; CONST AllBtns: Boolean = False);

Parameters

  • New: Boolean; The enabled state to apply to the selected buttons.
  • AllBtns: Boolean; Include spacers and dynamic script buttons when True.

Set_All_Buttons_Visible

Changes ordinary, non-script buttons. Pass AllBtns=True to include spacers and dynamic script buttons.
Procedure ThBA_Foundation.Set_All_Buttons_Visible(CONST New: Boolean; CONST AllBtns: Boolean = False);

Parameters

  • New: Boolean; The visibility state to apply to the selected buttons.
  • AllBtns: Boolean; Include spacers and dynamic script buttons when True.

Set_All_Buttons_Auto_Translate

Changes auto-translation for ordinary, non-script buttons, then retranslates the captions.
Procedure ThBA_Foundation.Set_All_Buttons_Auto_Translate(New: Boolean);

Parameters

  • New: Boolean; If True, enables translation. If False, uses static captions.

Set_All_Buttons_Lock_Release_UI

Changes ordinary, non-script buttons. Pass AllBtns=True to include all items.
Procedure ThBA_Foundation.Set_All_Buttons_Lock_Release_UI(CONST New: Boolean; CONST AllBtns: Boolean = False);

Parameters

  • New: Boolean; If True, enables UI lock/release logic. If False, disables it.
  • AllBtns: Boolean; Include spacers and dynamic script buttons when True.

Toggle_Radio_Buttons

Sets the named button Down and clears other buttons of the same type. An empty name clears all buttons of that type.
Procedure ThBA_Foundation.Toggle_Radio_Buttons(DownButtonName: String; ButtonType: ThButtonType = he_RadioBtn);

Parameters

  • DownButtonName: String; The internal name of the button to set as active.
  • ButtonType: ThButtonType; The type of buttons affected (default is he_RadioBtn).
ThButtonType = (he_Button, he_UpDown, he_Checkbox, he_RadioBtn, he_Spacer);
The record helper returns the enum member name as RawByteString; for he_RadioBtn the result is 'he_RadioBtn'.
Function ThButtonType_Helper.ToString: RawByteString;

Any_Button_Down

Checks whether any button of a given type is currently pressed (down state).
Function ThBA_Foundation.Any_Button_Down(ButtonType: ThButtonType): Boolean;

Parameters

  • ButtonType: ThButtonType; The type of buttons to check for active (down) state.

Return Value

Returns True if any button of the given type is currently down.
Returns False otherwise.

Down

Checks whether a specific button is currently in the down (pressed) state.
Does not raise an exception if the button is not found.
Function ThBA_Foundation.Down(CONST ButtonName: String): Boolean;

Parameters

  • ButtonName: String; The internal name of the button to query.

Return Value

Returns True if the specified button is down.
Returns False if the button is up or does not exist.

Button_State

Sets the visibility and enabled state of a specific button by name.
Procedure ThBA_Foundation.Button_State(CONST ButtonName: String; Visible, Enabled: Boolean);

Parameters

  • ButtonName: String; The internal name of the button to modify.
  • Visible: Boolean; Controls the button’s visibility.
  • Enabled: Boolean; Controls whether the button can be clicked.

GlobalInit

Performs global initialization of the button area and all button items.
Typically called during form creation or dynamic layout generation.
Procedure ThBA_Foundation.GlobalInit;
Returns the preferred height of the button area based on the layout and button sizes.
Overrides the base method to ensure proper alignment and spacing.
Function ThButtonsArea.Recommended_Height: Word; Override;

Return Value

Returns the height in pixels that fits the current button layout.

Max_Button_Width

Calculates the maximum width of a single button, or the total width of all buttons if specified.
Function ThButtonsArea.Max_Button_Width(Sum_Total: Boolean = False): Integer;

Parameters

  • Sum_Total: Boolean; If True, returns the total width of all buttons. If False, returns only the widest single button.

Return Value

Returns the width in pixels based on the specified mode.

rt_Focus_After_ReleaseUI

Specifies the control that should receive focus after the UI is released from a locked state.
Typically set during a button click event to return user interaction to a specific input field or control.
ThBA_Foundation.rt_Focus_After_ReleaseUI: TWinControl;

Busy

Indicates whether the button area is currently in a "busy" state (e.g. executing an action or locked).
When True, new interactions like clicks may be deferred or ignored.
Property ThBA_Foundation.Busy: Boolean;

Buttons

Returns the collection of buttons contained in the button area.
Each item is a ThButtonItem that defines its behavior, style, and state.
Property ThBA_Foundation.Buttons: ThButtonItems;

Layout

Defines the overall layout strategy for arranging buttons within the area.
Values are specified using the ThButtonsArea_Layout enumeration.
Property ThButtonsArea.Layout: ThButtonsArea_Layout;
 
ThButtonsArea_Layout = (he_Horizonal, he_Vertical, he_HorizIconsBar, he_VertIconsBar, he_Matrix, he_PopupMenu, he_Tiles);

Fix_Width

Specifies a fixed width (in pixels) for the button area.
Use -1 to allow dynamic width adjustment based on parent layout.
Property ThButtonsArea.Fix_Width: Integer Read FFix_Width Write Set_FixWidth Default -1;

Fix_Height

Specifies a fixed height (in pixels) for the button area.
Overrides automatic height calculation from content if set.
Property ThButtonsArea.Fix_Height: Integer Read FFix_Height Write Set_FixHeight Default 32;

White_Skin

If True, applies a white or light color theme to the button area.
Used to override default system or dark UI styling.
Property ThButtonsArea.White_Skin: Boolean Read FWhite_Skin Write Set_White_Skin Default False;

Script_Integration

Exposes integration features that allow the button area to connect with an external scripting system.
Used to bind scripted actions or automate button behavior dynamically.
Property ThButtonsArea.Script_Integration: Boolean;

StrClick

Event triggered when a string-identified button is clicked by the user.
Enables high-level handling of named button events without requiring control references.
Property ThBA_Foundation.StrClick: Thba_StrClickEvent;

Thba_StrClickEvent

Event handler type triggered when a button is clicked, identified by its internal string name.
Used to handle user interactions without requiring direct button object references.
Thba_StrClickEvent = Procedure (ButtonName: String; Sender: ThButtonItem) OF Object;

Parameters

  • ButtonName: String; The internal name of the button that was clicked.
  • Sender: ThButtonItem; The actual button object that triggered the event.

StrRightClick

Event triggered when the user right-clicks on a button, identified by name.
Used to show context menus or handle alternate actions for specific buttons.
Property ThBA_Foundation.StrRightClick: Thba_StrRightClickEvent;

Thba_StrRightClickEvent

Event handler type triggered when the user right-clicks a button in the button area.
Provides access to both the clicked button and its owning button area container.
Thba_StrRightClickEvent = Procedure (Btn_Item: ThButtonItem; BA_Comp: ThBA_Foundation) OF Object;

Parameters

  • Btn_Item: ThButtonItem; The button that was right-clicked.
  • BA_Comp: ThBA_Foundation; The button area component containing the button.

Before_Popup

Standard VCL-style event triggered before a popup is shown by a button action.
Allows cancellation, styling, or data binding just prior to display.
Property ThBA_Foundation.Before_Popup: TNotifyEvent;

Set_Button_Down

Sets the Down state of a named button. An unknown name is ignored.
Procedure ThBA_Foundation.Set_Button_Down(CONST ButtonName: String; New: Boolean);

Set_Button_Thread

Sets threaded execution and UI locking for a named button. An unknown name is ignored.
Procedure ThBA_Foundation.Set_Button_Thread(CONST ButtonName: String; Run_Under_New_Thread, Lock_Release_UI: Boolean);

Kill_Thread_IF_Running

Requests immediate termination of the running button thread. This path can leak thread memory.
Function ThBA_Foundation.Kill_Thread_IF_Running: Boolean;

ThButtonItems

Represents the collection of buttons managed by a ThButtonsArea control.
Each item in the collection is a ThButtonItem that defines a specific button's caption, icon, event handlers, and behavior flags.
Provides indexed and name-based access to buttons, along with methods for dynamic layout and state manipulation.
Used internally by the button area to render, interact with, and control its visual button set.
Supports dynamic creation, modification, and serialization of user-defined or scripted button definitions.

Add

Creates and adds a new, empty button item to the collection.
The button can be configured manually after creation.
Function ThButtonItems.Add: ThButtonItem;

Return Value

Returns the newly created ThButtonItem instance.

AddNew

Adds a fully defined button to the collection, using the specified name, icon, caption, and behavior settings.
Used when creating button definitions at runtime or through scripting.
Function ThButtonItems.AddNew(Name, Bmp_Icon, Caption: String; ButtonType: ThButtonType = he_Button; HotTrack: Boolean = False;
                Location: ThButtonLocation = he_FromStart; Down: Boolean = False): ThButtonItem;

Parameters

  • Name: String; The internal name used to reference the button.
  • Bmp_Icon: String; The name of the bitmap icon assigned to the button.
  • Caption: String; The text displayed on the button surface.
  • ButtonType: ThButtonType; Defines the visual and functional style of the button (default is he_Button).
  • HotTrack: Boolean; If True, enables hover highlight effect.
  • Location: ThButtonLocation; Determines where to place the button relative to others (default is he_FromStart).
  • Down: Boolean; Sets the initial "down" state (pressed) of the button.

Return Value

Returns the newly added and configured ThButtonItem instance.

Example

Assume ButtonsArea is a ThButtonsArea component. The icon name may be empty.
with ButtonsArea.Buttons.AddNew('save', '', 'Save', he_Button) do
  HotKey_Desc := 'F2';
ButtonsArea.GlobalInit;

Items

Provides indexed access to the button items in the collection.
Each item can be used to control button behavior, appearance, and events.
Property ThButtonItems.Items[Index: Integer]: ThButtonItem;

Parameters

  • Index: Integer; The zero-based index of the button in the list.

Return Value

Returns the ThButtonItem at the specified index.

ThButtonItem

Represents a single button within a ThButtonsArea control.
Encapsulates the button’s properties such as name, caption, icon, state, visibility, and behavior type.
Supports optional threading, click events, toggle modes, UI locking, auto-translation, and layout customization.
Designed for high-level integration with wizards, dialogs, and dynamic button panels in SYE-based applications.
Used by ThButtonItems to define, control, and render individual interactive buttons.

Final_Caption_String

Returns the final caption string that will be displayed on the button, optionally including the hotkey indicator.
Applies auto-translation and formatting as needed.
Function ThButtonItem.Final_Caption_String(Inc_HotKey: Boolean = True): String;

Parameters

  • Inc_HotKey: Boolean; If True, includes hotkey symbol (e.g., ampersand) in the result.

Return Value

Returns the fully formatted caption string as it will appear on the button.

Popup_Screen_Coords

Returns the screen coordinates where a popup related to this button should appear.
Used to anchor menus or overlays to the button’s position.
Function ThButtonItem.Popup_Screen_Coords: TPoint;

Return Value

Returns a TPoint representing the screen coordinates for popup alignment.

Dyn_For_Script

Returns True when the owning button area has Script_Integration enabled and the button name starts with Dynamic_.
Function ThButtonItem.Dyn_For_Script: Boolean;

Return Value

Returns True if the button was created by script integration.
Returns False if the button is static or design-time defined.

rt_Skip_Next_ReleaseUI

If set to True, prevents the automatic UI release after the next button click.
Used when the button's logic intentionally retains the UI in a locked state (e.g., for nested or chained operations).
This flag is reset automatically after being applied once.
ThButtonItem.rt_Skip_Next_ReleaseUI: Boolean;

rt_ITag

Four integer slots for application-specific runtime data on this button item.
ThButtonItem.rt_ITag: Array[1..4] OF Integer;

Enabled

Controls whether the button is interactive and can receive user clicks.
When False, the button is grayed out and cannot be activated.
Property ThButtonItem.Enabled: Boolean;

Visible

Determines whether the button is currently visible in the button area layout.
When False, the button is hidden but still exists in the collection.
Property ThButtonItem.Visible: Boolean;

Name

Specifies the internal name of the button, used for scripting, event handling, and runtime identification.
Must be unique within the parent button area.
Property ThButtonItem.Name: String;

Caption

Defines the text displayed on the button.
Can include hotkey markers (e.g., &) and may be translated if auto-translate is enabled.
Property ThButtonItem.Caption: String;

ButtonType

Defines the visual style and behavior type of the button.
Values are defined by the ThButtonType enumeration (e.g., standard button, radio button, etc).
Property ThButtonItem.ButtonType: ThButtonType;

Bmp_Icon

Specifies the bitmap icon associated with the button, if any.
Used for visual identification or branding within the button area.
Property ThButtonItem.Bmp_Icon: String;

Location

Determines whether the button is placed from the start, from the end, or in the popup extension.
Uses the ThButtonLocation enumeration.
Property ThButtonItem.Location: ThButtonLocation;

HotTrack

If True, the button highlights visually when hovered by the mouse.
Used to enhance interactivity and visual feedback.
Property ThButtonItem.HotTrack: Boolean;

Auto_Translate

If True, the button’s caption is automatically translated using the application's current language settings.
If False, the caption is displayed as-is without localization.
Property ThButtonItem.Auto_Translate: Boolean;

HotKey_Desc

Defines a hotkey description string for tooltip or UI hints.
Does not affect actual keyboard shortcut behavior, but may appear in UI documentation or popups.
Property ThButtonItem.HotKey_Desc: String;

Down

Indicates whether the button is currently in the “pressed” state.
Primarily used for toggle and radio button types.
Property ThButtonItem.Down: Boolean;

Lock_Release_UI

If True, the UI will automatically be locked during button execution and released when done.
Used to prevent double-clicks or conflicting input during processing.
Property ThButtonItem.Lock_Release_UI: Boolean;

Run_Under_Thread

If True, the button’s action is executed under a background thread.
Allows long-running tasks to run without blocking the UI.
Property ThButtonItem.Run_Under_Thread: Boolean;

ThDialogFormTitle

A specialized title bar control designed for use at the top of modal dialogs or message forms.
Displays the dialog caption with optional icon and help behavior, styled according to the application's visual language.
Supports localization, theming (light/dark), alignment, and integration with ThStatusBar and ThButtonsArea components.
Intended to provide a consistent header experience across SYE-styled dialogs while remaining highly customizable and embeddable.
Built on TSYE_Control for future FMX compatibility and advanced layout management.
This class shares the same properties as ThButtonsArea, with several additional / different functions.

_Paint_Mouse_Flag

Controls whether mouse-related visual effects are painted on the title bar.
Set this to False when rendering the title visually for screen captures or printing purposes.
ThDialogFormTitle._Paint_Mouse_Flag: Boolean;

Auto_Caption_Trans

If True, the caption text is automatically translated using the current application language.
If False, the caption is used exactly as assigned without translation.
Property ThDialogFormTitle.Auto_Caption_Trans: Boolean;

Allow_To_Move_Form

Determines whether the user can click and drag the title area to move the parent form.
Set to False to disable window repositioning via the title bar.
Property ThDialogFormTitle.Allow_To_Move_Form: Boolean;

Caption

Defines the text displayed on the dialog title bar.
May be static or translated depending on the Auto_Caption_Trans setting.
Property ThDialogFormTitle.Caption: String;

Connect_Parent_Form_KeyDown_To_Me

Connects the parent form OnKeyDown handler to this title bar and enables KeyPreview. Call after the control has a parent form.
Procedure ThDialogFormTitle.Connect_Parent_Form_KeyDown_To_Me;

Send_KeyDown_To_Active_Form

Routes a key through the active form or frame manager; returns True when a handler sets Key to zero.
Function ThDialogFormTitle.Send_KeyDown_To_Active_Form(ScanOwner: TScrollingWinControl; VAR Key: Word; Shift: TShiftState): Boolean;

ThPopupMenu

A custom popup menu component designed to replace the standard VCL TPopupMenu with extended features.
Supports SYE-style appearance, Unicode text, icons, dynamic item population, and integration with multi-language applications.
Built for use in modern UIs requiring consistent theming, localization, and flexible command handling.
Compatible with both static menu definitions and dynamically generated items at runtime.
Intended for seamless usage alongside other SYE components with a focus on lightweight UI overlays.

Parent_Anchor

Sets the owning window and monitor for the popup. Popup(PinPosition) still uses the supplied screen coordinates.
ThPopupMenu.Parent_Anchor: TWinControl;

Add_New_Button

Creates and adds a new button item to the popup menu with the specified name, caption, and icon.
Supports optional auto-translation of the caption.
An empty Name or Caption is rejected.
Function ThPopupMenu.Add_New_Button(Name, Caption, Bmp_Icon: String; Auto_Translate: Boolean = False): ThButtonItem;

Parameters

  • Name: String; Internal identifier for the button.
  • Caption: String; Text displayed on the button.
  • Bmp_Icon: String; Bitmap icon name to associate with the button.
  • Auto_Translate: Boolean; If True, enables automatic translation of the caption.

Return Value

Returns the created ThButtonItem, or nil when Name or Caption is empty.

Button

Retrieves a button item from the popup menu by its internal name.
Function ThPopupMenu.Button(ButtonName: String): ThButtonItem;

Parameters

  • ButtonName: String; The internal name of the button to retrieve.

Return Value

Returns the corresponding ThButtonItem, or nil if not found.

Set_All_Buttons_Enabled

Enables or disables all buttons in the popup menu.
Useful for globally locking or unlocking menu interaction.
Procedure ThPopupMenu.Set_All_Buttons_Enabled(New: Boolean);

Parameters

  • New: Boolean; If True, enables all buttons. If False, disables them.

Set_All_Buttons_Visible

Shows or hides all buttons in the popup menu.
Procedure ThPopupMenu.Set_All_Buttons_Visible(New: Boolean);

Parameters

  • New: Boolean; If True, makes all buttons visible. If False, hides them.

Close

Closes the popup menu and hides it from view.
Used to programmatically dismiss the menu after selection or cancellation.
Procedure ThPopupMenu.Close;

Popup

Reads the current mouse cursor position and opens the popup there. Parent_Anchor selects the owning window when it is assigned.
Procedure ThPopupMenu.Popup; Overload;

Popup (PinPosition)

Displays the popup menu at a specific screen position.
Used for absolute placement of the popup regardless of its parent control.
Procedure ThPopupMenu.Popup(PinPosition: TPoint); Overload;

Parameters

  • PinPosition: TPoint; The screen coordinates at which to display the popup.

Buttons

Returns the collection of buttons displayed within the popup menu.
Each item is a ThButtonItem defining the behavior and appearance of a menu command.
Property ThPopupMenu.Buttons: ThButtonItems;

LocalLang

If True, uses a locally defined language context for the popup menu.
Overrides the global application language if set.
Property ThPopupMenu.LocalLang: Boolean;

Usage_Notes

A custom string field that can be used to store notes, hints, or script binding references related to the popup menu.
Has no visual effect but may be referenced programmatically.
Property ThPopupMenu.Usage_Notes: String;

OnClick

Called for a selected popup button; the handler receives its name.
Property ThPopupMenu.OnClick: Thpm_StrClickEvent;

Thpm_StrClickEvent

Event handler type used for a popup command.
Provides the internal name of the button as the identifier for logic execution.
Thpm_StrClickEvent = Procedure (ButtonName: String) OF Object;

Parameters

  • ButtonName: String; The internal name of the clicked popup menu button.

Button_State

Sets visibility and enabled state of a named popup command. An unknown name is ignored.
Procedure ThPopupMenu.Button_State(CONST ButtonName: String; Visible, Enabled: Boolean);

Busy

Read-only flag indicating that a popup command is running.
Property ThPopupMenu.Busy: Boolean;