by Michael Hutton. May 2009
This style of progress bar is useful to show when you don't know the total time a process may take but you would like to inform the user something is going on. It requires Windows XP or above. See below for a full example program to copy into an IDE.
You need WINLIB3 and some constants.
INSTALL @lib$ + "WINLIB3"
PBS_MARQUEE = &8 PBM_SETMARQUEE = 1034
Please note that these constants are not in the WINCONST utility database yet.
Next, create and show the progress bar:
pb% = FN_createprogressbar(@hwnd%,20,200,200,20,PBS_MARQUEE) PROC_showprogressbar(pb%,100)
To, start the animation of the prograss bar:
SYS "SendMessage", !pb%, PBM_SETMARQUEE, 1, 10
where, !pb% is the handle to the progress bar, PBM_SETMARQUEE is the message, 1 is a Boolean (ie either 1 or 0) value to start and stop the animation, and 10 is an update time in milliseconds.
You can now stop/start and change the speed of the progress bar anytime by sending the PBM_SETMARQUEE message.
Don't forget to close the progress bar when you have finished with it.
PROC_removeprogressbar(pb%)
Copy the code below into a new IDE:
REM Getting a MARQUEE Progress Bar INSTALL @lib$ + "WINLIB3" REM!WC WIndows Constants (PB*_*MARQUEE NOT in WINCONST!) PBS_MARQUEE = &8 PBM_SETMARQUEE = 1034 REM Create a progress bar pb% = FN_createprogressbar(@hwnd%,20,200,200,20,PBS_MARQUEE) PROC_showprogressbar(pb%,100) pb1% = FN_createprogressbar(@hwnd%,20,240,200,20,PBS_MARQUEE) PROC_showprogressbar(pb1%,100) :\ \\ To start and stop the animation send the following message: \\ where wparam = boolean start/stop (1/0) \\ lparam = time delay between animation update (speed of marquee) \\ \\ Notice the exclamation mark before pb% and pb1% this is the *Handle* to \\ the progress bar. \ SYS "SendMessage", !pb%, PBM_SETMARQUEE, 1, 10 SYS "SendMessage", !pb1%, PBM_SETMARQUEE, 1, 50 PRINT "Press Space Bar." REPEAT REM Doing something else GCOL RND(7) CIRCLE FILL RND(1280),RND(1024),RND(50) UNTIL INKEY(2)=32 CLS PRINT "Stopping the first and speeding up the second." PRINT "Press Space again." :\ \\ Stop the top animation \\ Speed up the second \ SYS "SendMessage", !pb%, PBM_SETMARQUEE, 0, 0 SYS "SendMessage", !pb1%, PBM_SETMARQUEE, 1, 10 IF GET CLS PROC_removeprogressbar(pb%) PROC_removeprogressbar(pb1%) END