Progress bar from XbpPack2
Posted: Mon Jan 03, 2011 7:48 pm
Here is a program that uses the XbpPack2.Dll provided to Xbase++ subscribers from Alaska Software.
This dll contains a new class: XbpProgressBar.
I have created a sample program that shows how to use this class in eXpress++ applications.
This sample program includes a new class named WaitProgress that you can use as a replacement for DC_WaitOn() and for other uses.
Create a new folder named \exp19\samples\XbpPack and unzip the attached files in that folder, then run pbuild Progress.xpj.
This dll contains a new class: XbpProgressBar.
I have created a sample program that shows how to use this class in eXpress++ applications.
This sample program includes a new class named WaitProgress that you can use as a replacement for DC_WaitOn() and for other uses.
Create a new folder named \exp19\samples\XbpPack and unzip the attached files in that folder, then run pbuild Progress.xpj.
Code: Select all
FUNCTION Main()
LOCAL GetList[0]
@ 0,0 DCPUSHBUTTON CAPTION 'Standard Please Wait Progress Bar' ;
SIZE 40,2 ACTION {||PleaseWait( 5 )}
@ 2,0 DCPUSHBUTTON CAPTION 'Backup Files Progress Bar' ;
SIZE 40,2 ACTION {||Backup(.f.)}
@ 4,0 DCPUSHBUTTON CAPTION 'Backup Files Progress Bar (w/cancel button)' ;
SIZE 40,2 ACTION {||Backup(.t.)}
DCREAD GUI FIT TITLE 'Progress Bars' SETAPPWINDOW
RETURN nil
* -------------
FUNCTION PleaseWait( nSeconds )
LOCAL oProgress, i
DEFAULT nSeconds := 2
oProgress := WaitProgress():new()
oProgress:messageString := 'Doing some stuff. Please Wait...'
oProgress:title := 'Doing Stuff'
oProgress:progressStyle := XBPPRGR_STYLE_MARQUEE
oProgress:create()
FOR i := 1 TO nSeconds * 10
DC_CompleteEvents() // need this to move window
Sleep(10)
NEXT
oProgress:destroy()
RETURN nil
* -------------
FUNCTION Backup( lCancelButton )
LOCAL oProgress, aDir, i, j
DEFAULT lCancelButton := .f.
oProgress := WaitProgress():new()
oProgress:messageString := 'Backing up files. Please Wait...'
oProgress:title := 'File Backup'
oProgress:isCancelButton := lCancelButton
oProgress:create()
aDir := Directory()
FOR i := 1 TO Len(aDir)
oProgress:setData(0)
oProgress:statusObject:setCaption(aDir[i,1])
oProgress:progressObject:maximum := aDir[i,2]
FOR j := 1 TO aDir[i,2] STEP 200 // need this to move window
oProgress:setData( j )
DC_CompleteEvents()
IF oProgress:isCancelled
EXIT
ENDIF
NEXT
IF oProgress:isCancelled
EXIT
ENDIF
NEXT
oProgress:destroy()
RETURN nil