ignoring mouse clicks

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Currently, when my application needs to write/read to a
database, there is a time lag. In that time lag, a user
can click the same button multiple times causing my app
problems. I want to turn the mouse pointer arrow into an
hourglass and ignore mouse clicks until my app finishes
working. Most commercial apps I've looked at do this.
Is there an easy way to do this (ie. any built-in
controls in VS.NET or classes in MSDN)? Any suggestions
and/or code samples would be greatly appreciated. Thank
you for the reply.

Mike
 
A lot of times that behavior is because of single threading and the app is
simply waiting for the next line to complete. You could set the button's
enabled to false and then when the proc is done, set it back to true or wait
for whatever event to occur to tell it to be enabled.

You coudl do the similar thing by setting a bool and once the button is
clicked for the first time, set it to false. On the same click event, if
not myBool Exit Sub.
 
Mike,

Something along these lines:
-------------
Cursor = Cursors.WaitCursor;
// ... do processing
Cursor = Cursors.Arrow;
-------------

Is this what you were looking for?

Regards,
Alex
 
Currently, when my application needs to write/read to a
database, there is a time lag. In that time lag, a user
can click the same button multiple times causing my app
problems. I want to turn the mouse pointer arrow into an
hourglass and ignore mouse clicks until my app finishes
working. Most commercial apps I've looked at do this.
Is there an easy way to do this (ie. any built-in
controls in VS.NET or classes in MSDN)? Any suggestions
and/or code samples would be greatly appreciated. Thank
you for the reply.


when using C#, you could use teh -= operator on the Click-event (and
+= to re-subscribe after the processing)
 
That is exactly what I am looking for. Just one thing,
after I turn the cursor into a wait cursor, is there a
way to disable all the controls (e.g buttons, textboxes)
so that I can't click on anything, or do I have to
disable each control individually. Again , thanks for
the reply.
 
this.Enabled = false;

--
Horatiu Ripa
Software Development Manager
Business Logic Systems LTD
21 Victor Babes str., 1st floor, 3400 Cluj-Napoca, Romania
Phone/Fax: +40 264 590703
Web: www.businesslogic.co.uk

This email (email message and any attachments) is strictly confidential,
possibly privileged and is intended solely for the person or organization to
whom it is addressed. If you are not the intended recipient, you must not
copy, distribute or take any action in reliance on it. If you have received
this email in error, please inform the sender immediately before deleting
it. Business Logic Systems Ltd accepts no responsibility for any advice,
opinion, conclusion or other information contained in this email or arising
from its disclosure.
 
Back
Top