By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

WaitCursor with Disabled Forms

P: n/a
I am trying to show an hourglass mouse cursor and disable the main form
whilst waiting for some activity to finish. The problem I have come across is
that as soon as you disable the main form the cursor returns to the default
arrow.

Does anyone know of an alternative approach ?

It can be easily simulated with a project containing a single form with a
button and timer on as follows :

'-----------------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

'>>>This line works as expected showing the hourglass cursor...
Cursor = Cursors.WaitCursor
'>>>As soon as I call the next line the cursor returns to the default
arrow....
Me.Enabled = False

Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Timer1.Enabled = False
Me.Enabled = True
Me.Cursor = Cursors.Default

End Sub

'-----------------------------------------------------------------------------------------------
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lenster,

You are right, when you disables the complete form you disables everything
even the posiblility to close it.

When you remove that set the cursor to default sentence in the timer it will
be showed again as hourglass when it is enabled again.

You can of course set a docked panel on your form and use that, than you can
disable the panel as I did in the sample bellow

\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Cursor = Cursors.WaitCursor
Me.Panel1.Enabled = False
Timer1.Interval = 2000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Me.Panel1.Enabled = True
Me.Cursor = Cursors.Default
End Sub
///

I hope this helps?

Cor
"Lenster" <Le*****@discussions.microsoft.com>
I am trying to show an hourglass mouse cursor and disable the main form
whilst waiting for some activity to finish. The problem I have come across
is
that as soon as you disable the main form the cursor returns to the
default
arrow.

Does anyone know of an alternative approach ?

It can be easily simulated with a project containing a single form with a
button and timer on as follows :

'-----------------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

'>>>This line works as expected showing the hourglass cursor...
Cursor = Cursors.WaitCursor
'>>>As soon as I call the next line the cursor returns to the default
arrow....
Me.Enabled = False

Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Timer1.Enabled = False
Me.Enabled = True
Me.Cursor = Cursors.Default

End Sub

'-----------------------------------------------------------------------------------------------

Nov 21 '05 #2

P: n/a
Lenster,

You are right, when you disables the complete form you disables everything
even the posiblility to close it.

When you remove that set the cursor to default sentence in the timer it will
be showed again as hourglass when it is enabled again.

You can of course set a docked panel on your form and use that, than you can
disable the panel as I did in the sample bellow

\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Cursor = Cursors.WaitCursor
Me.Panel1.Enabled = False
Timer1.Interval = 2000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Me.Panel1.Enabled = True
Me.Cursor = Cursors.Default
End Sub
///

I hope this helps?

Cor
"Lenster" <Le*****@discussions.microsoft.com>
I am trying to show an hourglass mouse cursor and disable the main form
whilst waiting for some activity to finish. The problem I have come across
is
that as soon as you disable the main form the cursor returns to the
default
arrow.

Does anyone know of an alternative approach ?

It can be easily simulated with a project containing a single form with a
button and timer on as follows :

'-----------------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

'>>>This line works as expected showing the hourglass cursor...
Cursor = Cursors.WaitCursor
'>>>As soon as I call the next line the cursor returns to the default
arrow....
Me.Enabled = False

Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Timer1.Enabled = False
Me.Enabled = True
Me.Cursor = Cursors.Default

End Sub

'-----------------------------------------------------------------------------------------------

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.