473,237 Members | 1,223 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Ignoring Mouse Events During WaitCursor

In my Windows Forms application, while executing a process that takes some
time, I am changing the cursor to the hourglass by setting Cursor.Current =
Cursors.WaitCursor.

This is working just fine, except that any mouse events generated during
this wait period (such as clicking on a button, etc.), get processed once the
processing is complete. For example, while waiting for my task to complete,
I click on a button (even though the cursor is an hourglass). When the task
is complete, the button click event is executed.

The documentation for the Cursor.Current property makes it sound like the
application will stop listening for mouse events while the cursor is not set
to Cursors.Default, but this does not seem to be the case in practice.

Any advice? Is this a bug or am I doing something incorrectly?

Thanks!

-Karen
Nov 16 '05 #1
2 10025
Hi Karen,

Changing the shape of the mouse pointer has nothing to do with processing
mouse messages. Even when the mouse pointer is set to the hourglass, the
system still accumulates events received from the input devices (not only
the mouse, but also the keyboard and whatever device you can imagine). You
can probably forcibly clear the event queue with API calls upon the
completion of the task, but I'd consider it a hack and definitely a bad
programming style.

Why don't you use asynchronous delegates or multi-threading instead? This
way, the application won't be blocked while working on the long-running task
(that is, it will be able to repaint itself, the user will be able to
minimize and restore the window etc.), and at the same time you can disable
controls and menu items which shouldn't be available until the task
completes.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"KarenP" <Ka****@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
In my Windows Forms application, while executing a process that takes some
time, I am changing the cursor to the hourglass by setting Cursor.Current
=
Cursors.WaitCursor.

This is working just fine, except that any mouse events generated during
this wait period (such as clicking on a button, etc.), get processed once
the
processing is complete. For example, while waiting for my task to
complete,
I click on a button (even though the cursor is an hourglass). When the
task
is complete, the button click event is executed.

The documentation for the Cursor.Current property makes it sound like the
application will stop listening for mouse events while the cursor is not
set
to Cursors.Default, but this does not seem to be the case in practice.

Any advice? Is this a bug or am I doing something incorrectly?

Thanks!

-Karen


Nov 16 '05 #2
Hi Dmitriy,

Thank you for your response. I guess I misunderstood the documentation for
Cursor.Current. I do plan on running my task asynchronously and will be sure
to disable any controls that should not be available while the task is
running.

Thanks again,

Karen
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen Williams | last post by:
I am migrating a VB 6 PictureBox control to VB.NET. In VB 6, this control modified its border style during the mouse down and up events to provide user feedback that it was selected. Once...
1
by: Tee | last post by:
Hi, From my main form, I am executing another application using System.Diagnostics.Process.Start. The application has its own window displaying when the applicaiton is run. I want to change...
5
by: Mike | last post by:
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...
8
by: Eddie | last post by:
Hi All, I just want to change the mouse cursor during a process. I want a hourglass... How may I do it ? Thx
2
by: Alex | last post by:
Dear all How can I set the mouse form to a sand clock during I am executing something to indicate that the app is working. Once it's finished I would like to set the mouse form back to arrow....
3
by: Wayne Wengert | last post by:
In VB.NET is there a way to set the mouse cursor to the Wait cursor that will stay in effect across several forms? For example, I want to set the cursor to the WaitCursor in formA just before it...
2
by: Roberto Reale | last post by:
While developing a drag&drop enabled application I found out this "strange" behaviour: if I put a message box into the QueryContinueDrag event handler the message box is shown but the mouse cursor...
0
by: Gamey | last post by:
I have an application that NEEDS (don't ask) to handle additional mouse and keyboard processing during DoDragDrop. Normally, DoDragDrop kindly squashes all keyboard and mouse events. Alternate,...
6
by: Jan Heppen | last post by:
Is it posible to set something so that when my vb.net (visual studio 2005, framework 2.0) application is busy that the mouse pointer change into a hourglass ? Or do i have to set everywhere...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.