Friendly Hourglass Handling

by Ross Mack - GUI Computing

"...and from the darkness of his black cloak Death brought forth an hourglass of crystal and gold. Holding it up he watched the last grains of sand slip through to the lower chamber."

For much of the time the simplicity of using the Mousepointer property of Visual Basicís Screen object is enough to give the user sufficient indication that something is happening. It looks very professional when you use the mousepointer consistently on all form opens and closes and on all other time consuming code.

There are two problems with this, however. The first is that it is merely a visual indicator and does not really effect whether or not you can do anything with the mouse. The second is that when you perform a few tasks in a row in code you tend to get a flickering effect with the mousepointer changing from default pointer to hourglass and back with the beginning and end of each task. This problem becomes considerably worse on Windows NT or Windows 95 where animated Hourglasses are available. If you application keeps switching back to the default mousepointer then the animation keeps being interrupted and reset.

These little frustrations, that seem to crop up on every project, have caused me to develop a few simple procedures for handling the hourglass mousepointer. Basically, the idea is to keep a stack count of the number of requests for the hourglass. As each task starts it requests the hourglass, and when it stops it indicates that it no longer wants the hourglass. When the count of tasks that have requested the mousepointer is greater than one we set the mousepointer to an hourglass. As other tasks start and stop we only change the mousepointer back to default when the count of tasks has fallen back to zero.


Written by: Ross Mack
August 1995

Image of arrow to previous article Image of arrow to next article

[HOME] [TABLE OF CONTENTS] [SEARCH]