Cursor.Current

  • Thread starter Thread starter Armin Zingler
  • Start date Start date
A

Armin Zingler

Hello,

is it right that the cursor is *always* set back to it's default when the
application is idle?

cursor.current = cursors.waitcursor
'code taking some seconds
'after that the application is idle


Do I have to write
cursor.current = cursors.default
after the code above? Or even

dim c as cursor
c = cursor.current
cursor.current = cursors.waitcursor
'code taking some seconds
cursor.current = c

?

Thanks in advance
 
Hello Armin,

I would recommend always resetting the cursor shape to its default value
manually, preferrably in a finally block to ensure that the cursor is reset
to Default even when an exception is raised.
 
Armin Zingler said:
http://msdn.microsoft.com/library/e...systemwindowsformscursorclasscurrenttopic.asp

You probably know that I know this topic but it doesn't answer my
question.

I asked because setting it to the default cursor afterwards might be
wrong because it is possible that before setting it to
Cursors.Hourglass, it has not been the default cursor (e.g.
AppStarting).

One thing to add, and why I was a little confused:
Set a Form's cursor property to AppStarting. Add a button to the form. In
the Button_Click event handler add this code:

Cursor.Current = Cursors.WaitCursor
Cursor.Current = Cursors.Default

Start and click the button => the cursor is restored to AppStarting (as
expected).

Stop the app, and add a timer (Winforms Timer, interval=5000, enabled=true).
Add the same two lines in the timer's tick event handler. Start again, move
the mouse so that it is located over the form. Don't move it anymore! Wait
til the tick event fires => The cursor is *not* restored.

So, there is a difference between setting "Cursor.Current = Cursors.Default"
in a Button's click event and a Timer's tick event. I don't know why.
 
Back
Top