This is a class that will display a progress bar and allows you to cancel a process. It is fairly simple to use and implement. If you make any significant changes to this class. Please send them along to me.
[color blue]
*EXAMPLE
oPB = CREATEOBJECT("PROGRESSBAR","Title","Caption ")
*"Title" and "Caption " are Optional Paramaters
oPB.counter = 0
oPB.show
FOR x = 1 to 100 STEP +.01
IF TYPE('oPB.ButtonCancel')<>'U' THEN &&Cancel pushed?
oPB.counter = x
ELSE
x=101
ENDIF
NEXT x
IF TYPE('oPB.ButtonCancel')<>'U' THEN &&still exists?
oPB.Release
ENDIF [/color]
DEFINE CLASS "Progressbar" AS "FORM"
COUNTER = 0.5
BarCaption = ""
ButtonCancel =.F.
ALWAYSONTOP = .T.
AUTOCENTER = .T.
SHOWWINDOW = 2 && top level form
WINDOWTYPE = 1 && Modal
DRAWMODE = 9
TITLEBAR = 1
CONTROLBOX = .F.
HEIGHT = 83
WIDTH = 264+24
ADD OBJECT "oTxt" AS "TEXTBOX" WITH ;
HEIGHT = 25, LEFT =12, WIDTH = 264, ALIGNMENT = 2, ;
TOP = 6, BACKCOLOR = RGB(255,255,255), ;
DISABLEDBACKCOLOR = RGB(255,255,255), ;
DISABLEDFORECOLOR = RGB(0,0,0), ;
ENABLED = .F., FONTBOLD = .T.
ADD OBJECT "oCmd1" AS "COMMANDBUTTON" WITH ;
CAPTION = "\<Cancel", HEIGHT = 25, LEFT = 96, ;
WIDTH = 97, TOP = 48
PROCEDURE oCmd1.CLICK
nQuit = MESSAGEBOX('Are you sure you want to cancel?',4+32,thisform.caption)
If nQuit = 6 THEN
thisform.ButtonCancel =.T. &&abort search
thisform.release
ENDIF
ENDPROC
ADD OBJECT "oShp" AS "SHAPE" WITH ;
BORDERSTYLE = 0, DRAWMODE = 14, FILLSTYLE = 0
PROCEDURE INIT
PARAMETER cCaption, cBarCaption
IF EMPTY(cCaption) THEN
cCaption = ""
ENDIF
IF EMPTY(cBarCaption) THEN
cBarCaption = ""
ENDIF
thisform.oshp.left=thisform.oTxt.left+1
thisform.oshp.top=thisform.oTxt.top +1
thisform.oshp.height=thisform.oTxt.height-2
thisform.oshp.visible = .T.
thisform.borderstyle = 2
thisform.caption = cCaption
thisform.BarCaption = cBarCaption
ENDPROC
PROCEDURE Counter_assign
LPARAMETERS vNewVal
IF vNewVal <> thisform.counter THEN
IF vNewVal > 100 THEN
vNewVal = 100
ENDIF
thisform.counter = vNewVal
x = thisform.counter
thisform.oShp.width = x*thisform.oTxt.width/100
thisform.oTxt.value = thisform.BarCaption+ALLTRIM(STR(x))+"% Complete"
thisform.refresh
*Check if cancel button has been pushed Alt+C or clicked
IF MDOWN() OR CHRSAW() THEN
DOEVENTS
ENDIF
ENDIF
ENDPROC
ENDDEFINE
*EOF