HBasicControls: Pages and Tabs

HBasicControls overview
Arrange controls in bands and columns, then present pages in a tabbed interface.

ThPage

A lightweight container panel designed to function as a visual page within multi-page layouts or tabbed interfaces.
Used to host grouped controls that are shown or hidden as a logical unit during navigation or dynamic UI transitions.
Supports basic visibility, layout alignment, and theming through the SYE control system.
Built on TSYE_Control -> ThPage_Base for consistent rendering and future FMX compatibility.
Typically used in wizards, page flows, or content panels that toggle based on user actions or logic states.
Methods declared as ThPage_Base members are inherited by ThPage and can be called on a ThPage instance.

Get_Control_Location

Returns the position of a child control relative to the current page base origin.
Useful for alignment, animation, or layout validation within nested page structures.
Function ThPage_Base.Get_Control_Location(Find_Control: TControl): TPoint;

Parameters

  • Find_Control: TControl; The child control whose location should be calculated.

Return Value

Returns a TPoint indicating the X and Y offset of the control relative to this container.
Calculates the preferred height for the page layout, based on its content and visual rules.
Function ThPage_Base.Recommended_Height: Word; Override;

Return Value

Returns the height in pixels that best fits the content of the page.

Locate_Child_Controls

Performs layout positioning for all direct child controls inside the page.
Can optionally reset the internal layout index counter before arranging items.
Procedure ThPage_Base.Locate_Child_Controls(ResetCounter: Boolean = False);

Parameters

  • ResetCounter: Boolean; If True, resets the control index before layout begins.

Recurse_Locate_Child_Controls

Recursively applies layout positioning to all child controls and their descendants.
Useful for initializing deeply nested control trees inside complex page structures.
Procedure ThPage_Base.Recurse_Locate_Child_Controls;

Recurse_Set_Background_Color

Recursively applies a new background color to all child controls and their descendants.
Used to theme or update visual consistency across an entire page section.
Procedure ThPage_Base.Recurse_Set_Background_Color(NewColor: TColor);

Parameters

  • NewColor: TColor; The new background color to apply recursively to all nested elements.

Bottom_Space

Controls whether extra space is reserved at the bottom of the page for layout padding or visual separation.
Useful for maintaining visual gaps between grouped sections or page endings.
Property ThPage.Bottom_Space: Boolean Read FBottom_Space Write FBottom_Space Default True;

Bands

Defines the collection of layout bands (typically horizontal regions) managed by the page.
Used for structured layout where each band represents a logical or visual grouping of child controls.
Property ThPage.Bands: ThpBands;

White_Skin

If True, renders the page with a light or white-themed background and visual style.
Used for overriding default or dark-themed appearances.
Property ThPage.White_Skin: Boolean;

OnRelocate

Triggered during the page relocation flow after its child controls have been positioned.
Useful for refreshing linked UI elements or triggering dependent calculations.
Property ThPage.OnRelocate: TNotifyEvent;

ThpBands

Represents a collection of layout bands used within a ThPage component.
Each band serves as a horizontal visual container for grouping related controls inside the page.
The class provides management for band ordering, layout alignment, background coloring, and spacing behavior.
Used to structure complex page UIs into logical sections that can be measured, painted, or dynamically updated.
Implemented to support consistent cross-page visual rules within the SYE component framework.

Add

Creates and adds a new empty band item to the collection.
The returned item can then be configured manually with controls, dimensions, and alignment rules.
Function ThpBands.Add: ThpBandItem;

Return Value

Returns the newly created ThpBandItem instance added to the collection.

Add_By_Code

Adds a new band item with full configuration of its content, dimensions, alignment, and layout behavior.
Used when generating layout structure dynamically from code logic.
Function ThpBands.Add_By_Code(Col1_Control, Col2_Control: TControl;
                     Col1_Width, Col2_Width, FixedHeight: Word;
                     Align: ThPageAlign; AS_Index: Integer;
                     Horizontal_Space, Vertical_Space, Shrinkable: Boolean): ThpBandItem;

Parameters

  • Col1_Control: TControl; First control to appear in the band (left or top depending on flow).
  • Col2_Control: TControl; Second control placed beside the first one.
  • Col1_Width: Word; Width assigned to the first column.
  • Col2_Width: Word; Width assigned to the second column.
  • FixedHeight: Word; The fixed height of the band row.
  • Align: ThPageAlign; Alignment mode controlling how the band is placed in its parent.
  • AS_Index: Integer; Required argument; pass -1 to append, or a nonnegative index to reposition the new band.
  • Horizontal_Space: Boolean; Enables horizontal spacing between controls.
  • Vertical_Space: Boolean; Enables vertical padding around controls.
  • Shrinkable: Boolean; Indicates whether the band can shrink if space is limited.

Return Value

Returns the ThpBandItem created and added to the layout structure.

Example

Assume Page is a ThPage and NameEdit and ValueEdit are controls parented to that page.
Page.Bands.Add_By_Code(NameEdit, ValueEdit, 90, 0, 0,
  HpaTop, -1, True, True, False);
Page.Locate_Child_Controls(True);

Items

Provides indexed access to individual band items within the ThpBands collection.
Each item represents a visual band containing up to six controls with layout rules.
Property ThpBands.Items[Index: Integer]: ThpBandItem;

Parameters

  • Index: Integer; The zero-based index of the band to retrieve or modify.

Return Value

Returns the ThpBandItem at the specified index.

ThpBandItem

Defines a single horizontal layout band used within the ThpBands collection of a page container.
Each band typically holds several controls (columns) and defines their size, alignment, and spacing behavior.
Provides configuration for fixed dimensions, spacing, shrink rules, and vertical alignment within the page.
Used to create structured form layouts, grouped input sections, or dynamic page regions with consistent positioning.
Implemented to support visual clarity and modular control arrangement across ThPage_Base containers.

Safe_Control_Name

For a column ID from 1 through 6, returns the control name when it is a direct child of the owning page.
Returns an empty string when no matching control is available; returns 'Error!' if the guarded lookup raises an exception.
Function ThpBandItem.Safe_Control_Name(_ID: Word): String;

Col1_Control

Specifies the first control placed in the band layout.
This control appears in the first column of the band.
Property ThpBandItem.Col1_Control: TControl;

Col1_Width

Defines the width of the first column in pixels.
Property ThpBandItem.Col1_Width: Word;

Columns 2 through 6

Each band can hold up to six controls. Set each matching Width to a pixel value, or leave it at zero for layout calculation.
Property ThpBandItem.Col2_Control: TControl;
Property ThpBandItem.Col2_Width: Word;
Property ThpBandItem.Col3_Control: TControl;
Property ThpBandItem.Col3_Width: Word;
Property ThpBandItem.Col4_Control: TControl;
Property ThpBandItem.Col4_Width: Word;
Property ThpBandItem.Col5_Control: TControl;
Property ThpBandItem.Col5_Width: Word;
Property ThpBandItem.Col6_Control: TControl;
Property ThpBandItem.Col6_Width: Word;

Horizontal_Space

If True, horizontal spacing is applied between controls within the band.
Useful for maintaining consistent visual gaps across column elements.
Property ThpBandItem.Horizontal_Space: Boolean;

Vertical_Space

If True, vertical padding is added above and below the band’s content.
Used to ensure visual breathing room between stacked bands.
Property ThpBandItem.Vertical_Space: Boolean;

Align

Determines how the band aligns within its parent container.
Values are defined by the ThPageAlign enumeration (e.g. top, center, bottom).
Property ThpBandItem.Align: ThPageAlign;
 
ThPageAlign = (HpaTop, HpaMiddleStretch, HpaBottom);

Shrinkable

If True, allows the band to shrink when layout space is constrained.
Commonly used in responsive or dynamic UIs to prevent overflow.
Property ThpBandItem.Shrinkable: Boolean;

FixedHeight

Specifies a fixed height in pixels for the band. Values below 4 are raised to 4.
Property ThpBandItem.FixedHeight: Word;

Mouse_HorizDrag

If enabled, allows horizontal dragging behavior from within this band.
Intended for advanced layout or user interaction features.
Property ThpBandItem.Mouse_HorizDrag: Boolean;

Mouse_VertDrag

If enabled, allows vertical dragging behavior from within this band.
Useful for dynamic layout adjustments via user input.
Property ThpBandItem.Mouse_VertDrag: Boolean;

ThPageControl

A custom multi-page container that manages a collection of ThPage instances.
Designed to behave like a simplified and theme-aware tab control.
Provides runtime navigation between logical pages, automatic sizing, and centralized layout management.
Built on TSYE_Control and aligned with the SYE framework's styling and layout philosophy.
Commonly used in forms and dialogs that organize content into visible tabs.
For a step-by-step flow, set ActivePageName to show a named visible page, or call Rotate_Next_Page to advance to the next visible page.

rt_UserInt_Enabled

When False, the page control suppresses its own painting. This public field is not a general input lock.
ThPageControl.rt_UserInt_Enabled: Boolean;

Refresh

Forces a visual update of the page control and its active child page.
Overrides the base method to apply SYE-specific invalidation and repaint logic.
Procedure ThPageControl.Refresh; Override;

GlobalInit

Initializes all internal structures and prepares the page control for use.
Typically called during form creation or dynamic control setup to finalize layout and state.
Procedure ThPageControl.GlobalInit;
Calculates the preferred height of the page control based on its active page and layout rules.
Function ThPageControl.Recommended_Height: Word; Override;

Return Value

Returns the height in pixels that best fits the current content of the control.

PageItem

Retrieves a specific page item from the control by its internal name.
Used for runtime lookup or manipulation of a specific page within the control.
Function ThPageControl.PageItem(Name: String): THpcItem;

Parameters

  • Name: String; The unique name of the page to retrieve.

Return Value

Returns the THpcItem that matches the given name, or nil if not found.

ActivePage

Returns the currently active (visible) page managed by the page control.
Function ThPageControl.ActivePage: THpcItem;

Return Value

Returns the THpcItem that is currently active.
Returns the preferred height for the currently active page.
Allows layout managers to adjust to the specific needs of each page dynamically.
Function ThPageControl.ActivePage_Recommended_Height: Word;

Return Value

Returns the recommended height in pixels for the currently active page.

Register_TFrame

Associates a TFrame with a named page, optionally applying seamless parenting for layout embedding.
Used to dynamically assign visual content to a logical page during runtime initialization.
Procedure ThPageControl.Register_TFrame(ForPageName: String; RegFrame: TFrame; Seamless_Parenting: Boolean = False);

Parameters

  • ForPageName: String; The name of the page to associate with the frame.
  • RegFrame: TFrame; The frame to be hosted in the specified page.
  • Seamless_Parenting: Boolean; If True, aligns and anchors the frame to fit the page exactly.

SetFocus

Overrides the default focus behavior to ensure the currently active page receives focus.
Ensures proper keyboard handling and control activation within the visible page.
Procedure ThPageControl.SetFocus; Override;

Post_Hotkey_to_Active_Page

Offers a key to button areas and nested page controls on the active page. A handler sets Key to zero when it consumes the shortcut.
Procedure ThPageControl.Post_Hotkey_to_Active_Page(VAR Key: Word);

Parameters

  • Key: Word; The virtual key code to dispatch to the active page.

Rotate_Next_Page

Switches to the next logical page in the sequence.
Wraps around to the first page if the end of the list is reached.
Procedure ThPageControl.Rotate_Next_Page;

How_Many_Visible_Tabs

Returns the number of currently visible pages managed by the page control.
Used to count active (non-hidden) pages for layout or navigation purposes.
Function ThPageControl.How_Many_Visible_Tabs: Integer;

Return Value

Returns the total number of pages that are currently visible and accessible.

PageItem_Rt_Title_Suffix

Locates a page by name and sets rt_Title_Suffix to Qry.RowCount. If Qry is nil or empty, it uses _Empty_Title.
The tab is repainted shortly afterward.
Function ThPageControl.PageItem_Rt_Title_Suffix(PageName: String; Qry: ThTable; _Empty_Title: String = ''): THpcItem;

Parameters

  • PageName: String; The internal name of the page to update.
  • Qry: ThTable; The table whose RowCount becomes the suffix.
  • _Empty_Title: String; Optional fallback title if no data is available (default is empty).

Return Value

Returns the matching THpcItem, or nil when PageName is not found.

rt_Create_New_Page

Creates and adds a new page to the control with a specified name, icon, and title.
Supports optional auto-translation and explicit insertion index.
Function ThPageControl.rt_Create_New_Page(_Name, _Bmp_Icon, _Title: String; Auto_Translate: Boolean; Index: Integer = -1): ThPage;

Parameters

  • _Name: String; The internal name of the new page.
  • _Bmp_Icon: String; Icon name or resource to display for the page (if applicable).
  • _Title: String; The visible title of the new page.
  • Auto_Translate: Boolean; If True, the title is subject to language translation.
  • Index: Integer; Optional position at which to insert the new page (default is end of list).

Return Value

Returns the newly created ThPage instance.
After adding or deleting runtime pages, call GlobalInit to refresh the tabs and selected page.

Example

Assume PagesControl is a ThPageControl component:
PagesControl.rt_Create_New_Page('orders', '', 'Orders', True);
PagesControl.GlobalInit;
PagesControl.ActivePageName := 'orders';

rt_Delete_Page

Removes a page by its internal name from the page control.
Ensures the layout and internal state are updated accordingly.
Function ThPageControl.rt_Delete_Page(_Name: String): Boolean;

Parameters

  • _Name: String; The internal name of the page to delete.

Return Value

Returns True if the page was found and deleted.
Returns False if no such page exists.

ActivePageName

Gets or sets the internal name of the currently active page.
Switching the value will activate the corresponding page if it exists.
Property ThPageControl.ActivePageName: String;

TabOrder

Inherited property that determines the control's tab navigation order within its parent container.
Specifies the index used when navigating with the keyboard.
Property ThPageControl.TabOrder;

Pages

Returns the collection of pages managed by the control.
Each item in the collection is a THpcItem which represents a logical page.
Property ThPageControl.Pages: THpc_Collection;

Script_Integration

Enables script integration for the page control.
Property ThPageControl.Script_Integration: Boolean;

BorderLine

If True, draws a border line around the control's content area.
Useful for visually separating the control from surrounding UI elements.
Property ThPageControl.BorderLine: Boolean;

OnPageActive

Event triggered when a page becomes active (shown to the user).
Can be used to load data or refresh visual elements for the new page.
Property ThPageControl.OnPageActive: Thpc_ShowPageEvent;

Thpc_ShowPageEvent

Event handler type used by ThPageControl to notify when a new page becomes active.
Triggered during page transitions, allowing the application to perform updates or data loading.
Thpc_ShowPageEvent = Procedure (PageName: String; Sender: ThPageControl) OF Object;

Parameters

  • PageName: String; The internal name of the page that has become active.
  • Sender: ThPageControl; The page control that triggered the event.

OnRightClick

Event triggered when the user right-clicks on a page tab area.
Can be used to show context menus or trigger contextual logic.
Property ThPageControl.OnRightClick: Thpc_StrRightClickEvent;

Thpc_StrRightClickEvent

Event handler type used to respond to right-click actions on page tabs in a ThPageControl.
Enables context menu handling or interaction with a specific page item.
Thpc_StrRightClickEvent = Procedure (HPC_Item: THpcItem; HPC_Comp: ThPageControl) OF Object;

Parameters

  • HPC_Item: THpcItem; The page item that was right-clicked by the user.
  • HPC_Comp: ThPageControl; The page control component that owns the item.

THpc_Collection

Represents the internal collection of pages managed by a ThPageControl component.
Each item in the collection is a THpcItem that corresponds to a single logical page with metadata and visibility settings.
Provides indexed access, lookup by name, and helper methods for dynamic page manipulation.
Implements management logic for tab order, visibility, and page transitions within the SYE framework.
Used internally to coordinate rendering, navigation, and interaction for tabless page interfaces.

Items

Provides indexed access to the individual pages within the THpc_Collection.
Each item represents a page registered in the ThPageControl container.
Property THpc_Collection.Items[Index: Integer]: THpcItem Read GetItem Write SetItem; Default;

Parameters

  • Index: Integer; The zero-based index of the page to retrieve or modify.

Return Value

Returns the THpcItem instance at the specified index.

THpcItem

Represents a single logical page entry managed by a ThPageControl component.
Stores metadata such as the page name, title, icon, visibility status, and translation flags.
Provides linkage between the logical page definition and the actual ThPage instance it refers to.
Used internally for navigation, display, and page state management within the control's layout engine.
Acts as the bridge between page registration and runtime behavior in the SYE component framework.

rt_Title_Suffix

A runtime string that is appended to the page title for dynamic notifications or counts.
Typically used to display additional context such as record counts or alert indicators in the tab caption.
This suffix does not affect the base title and is managed separately at runtime.
THpcItem.rt_Title_Suffix: String;

rt_ITag

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

GetDisplayName

Returns the display name of the page item for use within the Delphi IDE or object inspector.
Overrides the default behavior to present a meaningful name based on the page's internal properties.
Function THpcItem.GetDisplayName: String; Override;

Return Value

Returns a string used for representing the page in the Delphi IDE.

Title_RT

Returns the current runtime title of the page, including any dynamic suffix (e.g. record count or notifications).
Function THpcItem.Title_RT: String;

Return Value

Returns the combined title string with the optional rt_Title_Suffix appended.

Hosted_Frame

Returns the TFrame instance hosted by this page item, if one was assigned.
Used when a frame has been registered to visually represent the page’s content.
Property THpcItem.Hosted_Frame: TFrame Read _Frame;

Name

Defines the internal name of the page, used for identification and programmatic access.
Must be unique within the ThPageControl collection.
Property THpcItem.Name: String Read FName Write Set_Name;

Title

Specifies the base title of the page, which may be displayed in the UI (e.g. tab header).
This title can be automatically translated and extended with runtime suffixes.
Property THpcItem.Title: String;

Bmp_Icon

Sets the name of a bitmap icon associated with the page.
The icon is used to visually represent the page in the tab header or indicator area.
Property THpcItem.Bmp_Icon: String;

Auto_Translate

If True, the page title is automatically translated according to the current application language.
If False, the title is displayed as-is, without translation.
Property THpcItem.Auto_Translate: Boolean;

Visible

Controls the visibility of the page within the page control.
If False, the page is excluded from navigation and rendering.
Property THpcItem.Visible: Boolean Read FVisible Write Set_Visible;

Page

References the actual ThPage instance associated with this item.
Used to access the visual content container bound to the page entry.
Property THpcItem.Page: ThPage;

Flat Function

Find_First_ThPage

Scans the direct child controls of the given form or frame and returns the first ThPage.
Function Find_First_ThPage(Form_Frame: TWinControl): ThPage;

Parameters

  • Form_Frame: TWinControl; The container to scan (usually a form or a frame).

Return Value

Returns the first ThPage instance found within the control hierarchy.
Returns nil if no page is found.