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
| 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
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
| Parameter
|
Type
|
Description
|
| owner
|
WinControl
|
The owner of the progress bar. This can be any object inherited from WinControl.
|
Returns
ProgressBar — The created ProgressBar object.
Properties
| 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
| 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
local form = createForm()
form.Caption = "ProgressBar Example"
form.Width = 400
form.Height = 150
local progressbar = createProgressBar(form)
progressbar.Parent = form
progressbar.Left = 20
progressbar.Top = 20
progressbar.Width = 340
progressbar.Height = 24
progressbar.Min = 0
progressbar.Max = 100
progressbar.Position = 25
form.show()
local form = createForm()
form.Caption = "Step Example"
form.Width = 400
form.Height = 150
local progressbar = createProgressBar(form)
progressbar.Parent = form
progressbar.Left = 20
progressbar.Top = 20
progressbar.Width = 340
progressbar.Height = 24
progressbar.Min = 0
progressbar.Max = 100
progressbar.Step = 10
local button = createButton(form)
button.Parent = form
button.Caption = "Step"
button.Left = 20
button.Top = 60
button.OnClick = function(sender)
progressbar.stepIt()
end
form.show()
local form = createForm()
form.Caption = "Timer Progress Example"
form.Width = 400
form.Height = 150
local progressbar = createProgressBar(form)
progressbar.Parent = form
progressbar.Left = 20
progressbar.Top = 20
progressbar.Width = 340
progressbar.Height = 24
progressbar.Min = 0
progressbar.Max = 100
progressbar.Position = 0
local timer = createTimer(form)
timer.Interval = 100
timer.OnTimer = function(sender)
progressbar.stepBy(1)
if progressbar.Position >= progressbar.Max then
sender.Enabled = false
end
end
form.show()
local progressbar = createProgressBar(getMainForm())
progressbar.Min = 0
progressbar.Max = 100
progressbar.setPosition2(50)
print("Progress: " .. tostring(progressbar.getPosition()))
Core Lua documentation entry points