Invoke a Quick Thermometer Bar for your Apps
by Carl Warner
I had a request to come up with something to show some end users where a long
batch job was as far as completion. If you don't throw some visual
cue out there, they occasionally think the app has frozen up and they end up
doing a premature re-boot. Ouch!! The task at hand was just to add it to some
existing code and no one wanted to have anything too fancy or intricate.
Plus, every so often, I see a request from someone in the Fox community of how
to create a thermometer bar or progress bar in their apps. And, quite
honestly, I have seen plenty of apps done by others that use no progress bars at
all as though they felt it was too hard or too confusing on how to use one.
So, if you don't use one, let's take the mystery out of it. If you do,
this probably isn't for you unless you don't use a quick and dirty method and
you haven't bothered to look for one.
The good news is that it is very easy to call up one and to increment it.
Of course, you can do all sorts of calculations to make the incrementing very
precise. But, in a quick and dirty world, that is unnecessary. Just
make a best guess as to your progress points and then just do it.
I tested this with VFP6 so I'm sure what I'm going to tell you to do is good as
far back as that version. I no longer have VFP3 or VFP5 installed
anywhere. But, I suspect they may also have this available in their
Foundation Classes as well.
What Do You Have To Do To Make It Work Quickly?
In a VFP project, add the _therm class library to the project. [I had
mine in a subfolder called "Libs" just below the application folder level.]
Then, in any other project app routine, use the following snippets of code to
make it work when you want it:
|
If you have a user that needs sound cues as well for an especially long process, you can easily add those at those same progress locations as the thermometer bar is incremented. And, if you have an understanding fun-loving user in an understanding fun-loving company (or you just want to surprise the heck out of someone because you're sure you won't get reprimanded or fired), you can add something like the following to sound off. If you simply copy and paste this code into your VFP Command Window and your VFP session is at the root folder of VFP where the _therm.vcx is right below it in the FFC folder, you can highlight this code block and right click it in the Command Window and select "Execute Selection".
|
_SCREEN.MOUSEPOINTER
= 11 ** supply your own attention grabbing sound files to replace the two I use here IF FILE("C:\Program Files\Windows NT\Pinball\SOUND999.WAV") SET BELL TO "C:\Program Files\Windows NT\Pinball\SOUND999.WAV" ENDIF
txtTitle = "Progress of Data Processing Routine" lotherm.Show ?? CHR(7) && You may have to "SET CONSOLE ON" to make this work and then "SET CONSOLE OFF" as a cleanup command =INKEY(2,"HM") loTherm. Update( 10, "Processing Calculations...")?? CHR(7) =INKEY(2,"HM") loTherm. Update( 30, "Processing Details...")?? CHR(7) =INKEY(2,"HM") loTherm. Update( 60, "Processing Summary Level Info...")?? CHR(7) =INKEY(2,"HM") loTherm. Update( 80, "Processing Logging Routine...")?? CHR(7) =INKEY(2,"HM") loTherm. Update(100, "Processing Is Complete...")IF FILE("C:\Program Files\Windows NT\Pinball\SOUND38.WAV") SET BELL TO "C:\Program Files\Windows NT\Pinball\SOUND38.WAV" ENDIF ?? CHR(7) =INKEY(2,"HM") SET BELL TO loTherm.Release ACTIVATE SCREEN _SCREEN.MOUSEPOINTER = 0 |
If the above is not sophisticated enough for you or you just are curious and want to see other references on the topic, here they are: