How to indicate to a computer user that a long or extended process is still working?
I have used Thermometers - but unless the process is really long, they just do not seem appropriate. I have tended to use Message Box's and Wait Windows, but again both of these have weaknesses. When a "Wait Window" stops appearing - that in itself does not indicate that a process is over - it could still be Looping! Message Box's call for the user to click buttons - this is not always appropriate. They might want to step away from their desk and processing will stop at the Message Box.
Then it suddenly occurred to me; why not get the command button to change the title and colour of the enclosing window! In VFP this can be done with a new class based upon the Command Button class. Only potential problem - can you call the default code for a class event; the Click event; more than once from within the events code of the object when placed on a form. Only one way to find out for sure - give it a go.
So created a New class based on the Commandbutton - called SV_CMDProcess.
Added 2 new properties to it
- SHOC (string - Hold Original form caption)
- NHOBC (numeric - hold original Background color)
Put the following code into the click event
LPARAMETERS pcallno
DO case
CASE m.pcallno = 1
this.shoc = thisform.Caption && save opening colour and caption
this.nhobc = thisform.backcolor
thisform.Caption = "P R O C E S S I N G" + Str(m.pcallno, 6)
thisform.backcolor = 255 &&RED
CASE m.pcallno > 1 and m.pcallno < 999999
IF (m.pcallno + 25) >= 16777215 THEN
thisform.backcolor = 255 && exceeding max value for white
ELSE
thisform.backcolor = thisform.backcolor + 25 && increment by arbitory value
ENDIF
thisform.Caption = "P R O C E S S I N G" + Str(m.pcallno, 6)
OTHERWISE
thisform.Caption = this.shoc && return colour and caption to original values
thisform.backcolor = this.nhobc
ENDCASE
thisform.refresh
Now when a form needs a command button to perform a process that will take 30secs to n minutes, I use this class and within its click event I can code the following:
dodefault(1) && initiate process
* process some data .....
FOR m.ix = 1 to m.Loopcount
dodefault(m.ix+1) && change colour/caption whilst processing data
ENDFOR
* end the process
dodefault(999999) && restore original colour and caption
During the processing the window shows the title "P R O C E S S I N G" followed by the number passed and the background colour starts as RED and then changes colour. This gives a visual indication to the user that processing is happening, but does not call for any action (as in a Message Box).
When finished the original caption and colour is restored.
Used alone or with WAIT Windows it provides an alternative way of communicating with the user whilst the computer is doing its work.
Being Christmas Eve as I write this - a Merry Christmas and New Year to all readers.
0 comments:
Post a Comment