$INCLUDE "windowssdk.inc" 'some constants so we can use the progress bar CONTROL CONST WM_USER = 0x400 CONST PBM_DELTAPOS = (WM_USER+3) CONST PBM_GETPOS = (WM_USER+8) CONST PBM_GETRANGE = (WM_USER+7) CONST PBM_SETBARCOLOR = (WM_USER+9) CONST PBM_SETPOS = (WM_USER+2) CONST PBM_SETRANGE = (WM_USER+1) CONST PBM_SETRANGE32 = (WM_USER+6) CONST PBM_SETSTEP = (WM_USER+4) CONST PBM_STEPIT = (WM_USER+5) setprecision 2 const PROGRESSBAR = 50 double filesize = 2097152 ' 2MB File size double ProgressBarRange = 200 'Progress bar range int Maxfilesize = filesize double UnitsToDo = filesize / ProgressBarRange int PercentDone,BasePercent int a,oldPercent BasePercent = ProgressBarRange / 100 WINDOW w1 OPENWINDOW w1,0,0,600,400,@MINBOX|@MAXBOX|@SIZE|@CAPTION,0,"Progress bar percent",&handler ProgressControl w1,40,80,ProgressBarRange,20,@BORDER|@PBS_SMOOTH,0,PROGRESSBAR SetProgressRange w1,PROGRESSBAR,0,Maxfilesize SetProgressStep w1,PROGRESSBAR,BasePercent CONTROL w1,@STATIC,"",40,120,200,25,@CTEDITLEFT|0x200,1 SETFONT w1,"Arial",12,400,0,1 SETCONTROLCOLOR w1,1,rgb(0,0,0),RGB(255,255,255) CONTROL w1,@STATIC,"",40,150,300,25,@CTEDITLEFT|0x200,2 SETFONT w1,"Arial",12,400,0,2 SETCONTROLCOLOR w1,2,rgb(0,0,0),RGB(255,255,255) 'Pretend we are downloading the file... for a = 1 to Maxfilesize 'a = actual number of bytes processed PercentDone = a / UnitsToDo if oldPercent <> PercentDone / BasePercent oldPercent = PercentDone / BasePercent setcontroltext(w1,1,"% " + ltrim$(str$(PercentDone / BasePercent))) setcontroltext(w1,2,"Processed " + ltrim$(str$(a)) + " of " + ltrim$(str$(Maxfilesize))) endif SetProgressPosition(w1,PROGRESSBAR,a) if iswindowclosed(w1) then breakfor wait 1 next a setcontroltext(w1,2,"100% complete.") WAITUNTIL IsWindowClosed(w1) end SUB handler(),INT SELECT @MESSAGE CASE @IDCREATE CENTERWINDOW w1 CASE @IDCLOSEWINDOW CLOSEWINDOW w1 ENDSELECT RETURN 0 ENDSUB