#include 'fivewin.ch'
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont, n
local nProgClr := RGB( 161, 224, 255 )
local aData := {}
XBrNumFormat( 'E', .t. )
for n := 1 to 20
AAdd( aData, { "File-" + StrZero( n, 2 ), 0, 0, 0 } )
next
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE DIALOG oDlg SIZE 600,360 PIXEL TRUEPIXEL ;
TITLE "Dynamic Progress Bars with XBrowse" ;
FONT oFont
@ 20,20 XBROWSE oBrw SIZE -20,-60 PIXEL OF oDlg ;
DATASOURCE aData COLUMNS 1,2,3, 4 ;
HEADERS "FileName", "Progress", "Complete", "Total" ;
COLSIZES 100,200,100,100 ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:lDisplayZeros := .f.
:lHScroll := .f.
:lVScroll := .f.
:bClrSel := :bClrSelFocus
:nStretchCol := 2
WITH OBJECT :aCols[ 2 ]
:nDataStrAlign := AL_CENTER
:SetProgBar( 100,, { || { nProgClr, CLR_WHITE } } )
:cEditPicture := "999.99 %"
:bClrSel := :bClrSelFocus := oBrw:bClrStd
END
//
:CreateFromCode()
END
@ 310, 20 BTNBMP PROMPT "Start" SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION DoProcess( oBrw )
@ 310,140 BTNBMP PROMPT "Cancel" SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION oBrw:Cargo := .f.
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
static function DoProcess( oBrw )
local n, i, nTotal
oBrw:GoTop()
for n := 1 to oBrw:nLen
nTotal := HB_RandomInt( 100, 2000 )
oBrw:aArrayData[ n, 4 ] := nTotal
oBrw:RefreshCurrent()
for i := 1 to nTotal STEP 10
SysWait( 0.01 )
// in case user disturbs the postion
oBrw:nArrayAt := n
oBrw:aArrayData[ n, 2 ] := i / nTotal * 100
oBrw:aArrayData[ n, 3 ] := i
oBrw:RefreshCurrent()
if oBrw:Cargo == .f.
EXIT
endif
next
if oBrw:Cargo == .f.
EXIT
endif
oBrw:nArrayAt := n
oBrw:aArrayData[ n, 2 ] := 100
oBrw:aArrayData[ n, 3 ] := nTotal
oBrw:RefreshCurrent()
oBrw:GoDown()
next
oBrw:oWnd:SayText( If( oBrw:Cargo == .f., "CANCELLED", "COMPLETED" ), ;
{ nil, nil, -20, -20 }, "RB" )
return nil
//----------------------------------------------------------------------------//