mousepointer property with DoEvents... for GURUS ;-)
Hi all,
this one is really for all the GURU specialists that are out there ;-) hope you can take me out of this.
Let's say that I have a project with:
- a MDI form (MDIform1);
- 2 child form (form1 and form2).
In fact, I actually have more than 2, and not all of them are visible at the same time. But let's keep it simple (did I say simple?!?).
On Form1 and Form2 I have labels which work as buttons (for graphical reasons I prefer using those instead of controls).
These buttons all have the mousepointer property set to 99 (custom icon), which is a small hand (like the one used for hyperlinks). So that when the mouse is over, the mousepointer changes, and the user understands it's a button (duh!).
Now, here the hard part begins. When you click on label1 of form1, I fire up a quite heavy routine. I therefore set my
form1.label1.mousepointer = 11 (hourglass), so that the mouse just stays at hourglass and the user just cannot start anything or click anything in the program until the heavy routine that he has started is done.
However I was not happy enough, since my routine can be quite long and I wanted my users to be able to stop it at anytime.
Therefore, I've put up a function that allows them to stop the routine by pressing the ESCAPE key (thanks Chris for this one!). In order to allow this stop, I am using the DoEvents property that allows to check for the key press.
The problem is: because of this DoEvents function, the mousepointer value is automatically set to 0 (default!), and therefore the user can click on other forms (which cause inevitable overflows, stacking,...).
Question: how can I solve this problem?
Things that I've tried:
1. setting MDIform.enabled = false
--> doesn't work. It's true, you can't press labels in the forms, but the mousepointer is 0 (arrow).
2. setting MDIform.mousepointer = 11
--> doesnt'work, same effect of form1.label1.mousepointer = 11, after the DoEvents the mouse is 0 again.
3. setting all the labels in all the forms to mousepointer = 11
--> could work, but then as I said not all the forms are loaded at the same time. This would mean setting up a verification to see which forms are active... seems long and not effective.
4. setting mousepointer = 11 after all the DoEvents
--> doesn't work, memory is overflooded, Stack problem.
5. ...any ideas?
All of you great GURUS, hope you can solve this one with me! Thanks for reading until here, you definitely would like to help if you kept on reading until these lines, so I already appreciate you efforts [^_^]
Best regards to you all,
W.