Click to See Complete Forum and Search --> : ignore events while hourglass


gbr
September 7th, 2005, 04:07 AM
Hi,

while I am executing a calculation I'd like to change the cursor to a hourglass to prevent the user switching the menu, etc. However the events seems to be stacked and executed when the cursor returns to normal state again.

How can I achieve to ignore mouse click events when the waitcursor is set?

Thanks,
gbr

jhammer
September 7th, 2005, 05:44 AM
I suggest you use flags.

jmcilhinney
September 7th, 2005, 05:55 AM
The cursor has nothing to do with whether events are raised or handled. You can set the cursor to whatever you want whenever you want and it has no effect on what the user can and can't do. It is simply a visual cue that you choose to provide. It's up to you and your code how to handle those pending events. They are pending until your operation is finished because your thread can only do one thing at a time. If you don't want the events raised in the first place then you would need to disable certain things while you do what it is you're doing. If you don't want to do that, then I suggest you do what jhammer suggests. I'd think he means that you set a boolean flag at the start of your operation and the call DoEvents at the end. In each of your event handlers you would test that flag and only act on the event if the flag is a particular value. Then you can toggle the flag back again after DoEvents and all your event handlers will behave normally again.

darwen
September 7th, 2005, 06:16 AM
The way that I use is not to use an hourglass, but to bring up a modal dialog box saying "Processing... please wait" or something.

Nice for the user to see, but it also means that all events are redirected to the dialog, so there's no problems.

Darwen.

gbr
September 7th, 2005, 06:38 AM
@darwen: yes, this seems to be a nice solution... thanks for your comments

klintan
September 7th, 2005, 08:04 AM
The way that I use is not to use an hourglass, but to bring up a modal dialog box saying "Processing... please wait" or something.

Nice for the user to see, but it also means that all events are redirected to the dialog, so there's no problems.

Darwen.

I just wondered why I never had experienced this problem, but I always use a modal dialog (usually also with an hourglass, progress bar, and a cancel button.... I don't know if it is correct from a GUI design perspective to have both hourglass and modal dialog and progress bar though).

zips
September 7th, 2005, 11:10 AM
Notice that when using WaitCursor m$ prevents ToolTips from showing.