Question

  • [Mouse cursor over window]: When I type in textboxes, on a .NET C# 4.0 window, the mouse cursor disappears and this is strange by itself.

  • [Mouse cursor outside window]: When I type in textboxes and press ENTER key to do some stuff in the UI thread, and then while doing that stuff, I move the mouse cursor over the window, the mouse disappears.

What can I do to keep the mouse always visible?

Was it helpful?

Solution

When typing in a text box (in any application) Windows will automatically hide your cursor. Some UI person will probably say that it's to prevent distractions, this is just my guess. If you move your mouse again, it will reappear.

The reason that your cursor is staying invisible while doing work in the UI thread is just that: Your application is busy doing work on the UI thread. Because your operation is happening there Windows is not able to redraw the area of the screen where your application is. That's why the mouse "disappears" again.

The two issues while manifesting similarly are different.

If you know that you need to do a lot of work, but it doesn't interact with the User Interface at all, you should kick off that work in a separate thread, so that your application continues to feel responsive to your user.

If you eventually need to do cause something to happen to the UI from another thread, you'll need to check out the Control.Invoke method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top