TProgress
Source: source/classes/tprogres.prg
Inherits from: TControl
TProgress wraps the Windows common control progress bar (msctls_progress32). It supports standard progress indication with configurable range and position, step increments, vertical orientation, and marquee (indeterminate) mode. TProgress is suitable for showing operation progress in windows, dialogs, and status bars.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nMin | Numeric | Minimum range value (default 0) |
nMax | Numeric | Maximum range value (default determined by system) |
nPos | Numeric | Current position |
nStep | Numeric | Step increment value |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, oWnd, nPos, nClrF, nClrB, lPixel, lDesign, nW, nH, cMsg, lVert, lMarquee ) | Create a progress bar. Supports vertical and marquee modes via lVert and lMarquee. |
ReDefine( nId, oWnd ) | Redefine from a dialog resource template |
SetPos( nPos ) | Set the current position (alias _nPosition, nPosition) |
GetPos() | Return the current position |
SetRange( nMin, nMax ) | Set the minimum and maximum range values |
SetStep( nStepInc ) | Set the step increment value |
StepIt() | Advance the position by the current step value |
DeltaPos( nIncrement ) | Change the position by a relative amount (positive or negative) |
SetMarquee( lOnOff ) | Enable or disable marquee (indeterminate) mode |
Commands
// Standard progress bar
DEFINE PROGRESS oProg OF oDlg
// Marquee (indeterminate) progress bar
DEFINE PROGRESS oProg OF oDlg MARQUEE
Example
#include "FiveWin.ch"
function Main()
local oWnd, oProg, n
DEFINE WINDOW oWnd TITLE "Progress Demo" SIZE 400, 150
@ 30, 30 PROGRESS oProg OF oWnd SIZE 340, 25
oProg:SetRange( 0, 100 )
oProg:SetStep( 1 )
@ 80, 30 BUTTON "Start" OF oWnd SIZE 80, 25 ;
ACTION ( oProg:SetPos( 0 ), ;
For n := 1 To 100,;
oProg:SetPos( n ),;
SysRefresh(),;
Sleep( 10 ),;
Next )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The progress bar uses the Windows common control class
msctls_progress32. - Marquee mode (indeterminate) shows an animated scrolling bar when the operation length is unknown. Enable via
lMarquee := .T.at creation or callSetMarquee( .T. )at runtime. - Vertical progress bars are created by setting
lVertical := .T.(stylePBS_VERTICAL). - The
StepIt()method advances the position by the value set viaSetStep(). The default step is 1. - Use
DeltaPos()for relative position changes without modifying the step value.