Difference between revisions of "Lua:Class:ProgressBar"

From Cheat Engine
Jump to navigation Jump to search
(Major overhaul of the post.)
m (Syntax Highlighting.)
 
Line 117: Line 117:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
local form = createForm()
 
local form = createForm()
 
form.Caption = "ProgressBar Example"
 
form.Caption = "ProgressBar Example"
Line 134: Line 134:
  
 
form.show()
 
form.show()
</pre>
+
</syntaxhighlight>
  
<pre>
+
<syntaxhighlight lang="lua" line>
 
local form = createForm()
 
local form = createForm()
 
form.Caption = "Step Example"
 
form.Caption = "Step Example"
Line 163: Line 163:
  
 
form.show()
 
form.show()
</pre>
+
</syntaxhighlight>
  
<pre>
+
<syntaxhighlight lang="lua" line>
 
local form = createForm()
 
local form = createForm()
 
form.Caption = "Timer Progress Example"
 
form.Caption = "Timer Progress Example"
Line 192: Line 192:
  
 
form.show()
 
form.show()
</pre>
+
</syntaxhighlight>
  
<pre>
+
<syntaxhighlight lang="lua" line>
 
local progressbar = createProgressBar(getMainForm())
 
local progressbar = createProgressBar(getMainForm())
  
Line 202: Line 202:
  
 
print("Progress: " .. tostring(progressbar.getPosition()))
 
print("Progress: " .. tostring(progressbar.getPosition()))
</pre>
+
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
 
{{Forms}}
 
{{Forms}}

Latest revision as of 19:30, 25 June 2026

{} Class

class ProgressBar : WinControl

The ProgressBar class represents a progress bar control.

A ProgressBar inherits from WinControl, Control, Component, and Object. It can display progress within a defined minimum and maximum range.

Inheritance[edit]

Class Inherits From Description
ProgressBar WinControl A visual progress bar control.
WinControl Control Base class for windowed controls.
Control Component Base class for visual controls.
Component Object Base class for components.

Creation[edit]

<> Lua API Reference

function createProgressBar(owner) : ProgressBar

Creates a ProgressBar object that belongs to the given owner.

The owner can be any object inherited from WinControl.

Function Parameters[edit]

Parameter Type Description
owner WinControl The owner of the progress bar. This can be any object inherited from WinControl.

Returns[edit]

ProgressBar — The created ProgressBar object.

Properties[edit]

Property Type Description
Min Integer The minimum position value the progress bar can have. The default is 0.
Max Integer The maximum position value the progress bar can have. The default is 100.
Position Integer The current position of the progress bar.
Step Integer The step size used when stepIt() is called.

Methods[edit]

Method Return Type Description
stepIt() void Increases the current position by the Step value.
stepBy(integer) void Increases the current position by the given integer value.
getMax() Integer Returns the Max property.
setMax(integer) void Sets the Max property.
getMin() Integer Returns the Min property.
setMin(integer) void Sets the Min property.
getPosition() Integer Returns the current Position property.
setPosition(integer) void Sets the current Position property.
setPosition2(integer) void Sets the current Position property without the slow progress animation on Windows 7 and later.

Examples[edit]

 1 local form = createForm()
 2 form.Caption = "ProgressBar Example"
 3 form.Width = 400
 4 form.Height = 150
 5 
 6 local progressbar = createProgressBar(form)
 7 progressbar.Parent = form
 8 progressbar.Left = 20
 9 progressbar.Top = 20
10 progressbar.Width = 340
11 progressbar.Height = 24
12 progressbar.Min = 0
13 progressbar.Max = 100
14 progressbar.Position = 25
15 
16 form.show()
 1 local form = createForm()
 2 form.Caption = "Step Example"
 3 form.Width = 400
 4 form.Height = 150
 5 
 6 local progressbar = createProgressBar(form)
 7 progressbar.Parent = form
 8 progressbar.Left = 20
 9 progressbar.Top = 20
10 progressbar.Width = 340
11 progressbar.Height = 24
12 progressbar.Min = 0
13 progressbar.Max = 100
14 progressbar.Step = 10
15 
16 local button = createButton(form)
17 button.Parent = form
18 button.Caption = "Step"
19 button.Left = 20
20 button.Top = 60
21 
22 button.OnClick = function(sender)
23   progressbar.stepIt()
24 end
25 
26 form.show()
 1 local form = createForm()
 2 form.Caption = "Timer Progress Example"
 3 form.Width = 400
 4 form.Height = 150
 5 
 6 local progressbar = createProgressBar(form)
 7 progressbar.Parent = form
 8 progressbar.Left = 20
 9 progressbar.Top = 20
10 progressbar.Width = 340
11 progressbar.Height = 24
12 progressbar.Min = 0
13 progressbar.Max = 100
14 progressbar.Position = 0
15 
16 local timer = createTimer(form)
17 timer.Interval = 100
18 timer.OnTimer = function(sender)
19   progressbar.stepBy(1)
20 
21   if progressbar.Position >= progressbar.Max then
22     sender.Enabled = false
23   end
24 end
25 
26 form.show()
1 local progressbar = createProgressBar(getMainForm())
2 
3 progressbar.Min = 0
4 progressbar.Max = 100
5 progressbar.setPosition2(50)
6 
7 print("Progress: " .. tostring(progressbar.getPosition()))

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes