WaitCursor with Disabled Forms


G

Guest

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

'-----------------------------------------------------------------------------------------------
 
Ad

Advertisements

C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top