Lua:Class:PageControl

From Cheat Engine
Revision as of 20:40, 26 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
Jump to navigation Jump to search

{} Class

class Pagecontrol : WinControl

The Pagecontrol class represents a control that can hold multiple pages.

Each page is represented by a TabSheet. A Pagecontrol can be created with createPageControl.

Inheritance

Class Inherits From Description
Pagecontrol WinControl Represents a multi-page tab control.
WinControl Control Base class for controls that can receive focus and contain child controls.
Control Component Base class for visible GUI controls.
Component Object Base class for components.
Object None Base class for Lua-exposed objects.

Creation

<> Lua API Reference

function createPageControl(owner) : Pagecontrol

Creates a Pagecontrol object that belongs to the given owner.

Function Parameters

Parameter Type Description
owner WinControl The owner of the page control.

Returns

Pagecontrol — The created page control object.

Properties

Property Type Description
ShowTabs Boolean Determines whether the tabs are shown.
TabIndex Integer Gets or sets the currently selected tab index.
ActivePage TabSheet Returns the currently active tab sheet.
PageCount Integer Returns the number of pages.
Page[index] TabSheet Returns the page at the specified index.

Methods

Method Return Type Description
addTab() TabSheet Creates a new TabSheet and adds it to the page control.
tabRect(index) Rect Returns a Rect table describing the position of the specified tab.

Rect Table

tabRect(index) returns a Rect table.

Field Type Description
Left Integer The left coordinate of the tab rectangle.
Top Integer The top coordinate of the tab rectangle.
Right Integer The right coordinate of the tab rectangle.
Bottom Integer The bottom coordinate of the tab rectangle.

Examples

Create a Pagecontrol

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.Left = 10
5 pageControl.Top = 10
6 pageControl.Width = 300
7 pageControl.Height = 200
8 
9 form.show()

Add pages

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 local firstPage = pageControl.addTab()
 5 firstPage.Caption = "General"
 6 
 7 local secondPage = pageControl.addTab()
 8 secondPage.Caption = "Advanced"
 9 
10 form.show()

Select a tab by index

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.addTab().Caption = "First"
5 pageControl.addTab().Caption = "Second"
6 
7 pageControl.TabIndex = 1
8 
9 form.show()

Read the active page

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "First"
 5 pageControl.addTab().Caption = "Second"
 6 
 7 pageControl.TabIndex = 0
 8 local activePage = pageControl.ActivePage
 9 
10 print(activePage.Caption)
11 
12 form.show()

Hide the tabs

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.ShowTabs = false
5 
6 pageControl.addTab().Caption = "Hidden Tab"
7 
8 form.show()

Enumerate pages

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "Page A"
 5 pageControl.addTab().Caption = "Page B"
 6 
 7 for i = 0, pageControl.PageCount - 1 do
 8   local page = pageControl.Page[i]
 9 
10   print(i .. ": " .. tostring(page.Caption))
11 end
12 
13 form.show()

Add controls to a TabSheet

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 local page = pageControl.addTab()
 5 page.Caption = "Settings"
 6 
 7 local label = createLabel(page)
 8 label.Caption = "This label belongs to the tab sheet"
 9 label.Left = 10
10 label.Top = 10
11 
12 form.show()

Get a tab rectangle

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "General"
 5 
 6 local rect = pageControl.tabRect(0)
 7 
 8 print("Left: " .. tostring(rect.Left))
 9 print("Top: " .. tostring(rect.Top))
10 print("Right: " .. tostring(rect.Right))
11 print("Bottom: " .. tostring(rect.Bottom))
12 
13 form.show()

Switch to the next tab

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "First"
 5 pageControl.addTab().Caption = "Second"
 6 
 7 if pageControl.PageCount > 0 then
 8   pageControl.TabIndex = (pageControl.TabIndex + 1) % pageControl.PageCount
 9 end
10 
11 form.show()

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes