automaticly change mouse pointer into hourglass

G

Guest

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 where my application do something
Windows.Forms.Cursor.Current = Cursors.WaitCursor ??

something is for example calling the sql-server database to get/set data

please help me
 
G

Guest

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 where my application do something
Windows.Forms.Cursor.Current = Cursors.WaitCursor ??

something is for example calling the sql-server database to get/set data

Well, you don't want to set WaitCursor at all times when your 'application
is busy'. Your app gets busy at Window's discretion more often than you
realize. However, you could probably detect busy status via
Application.AddMessageFilter. I advise against it.

What you could do is to set WaitCursor at the places where your app gets
'significantly' busy, and set CursorNormal in an Application.Idle event
handler. I would bookkeep your app's cursor status in a global variable so
that you can no-op attempts to set it to busy when it is already busy (or to
normal when it is already normal). You might want to set the cursor for all
forms in your app at the same time. All this suggests a sub whose calling
sequence takes a boolean busy-notbusy parameter.
 
G

Guest

AMercer said:
Well, you don't want to set WaitCursor at all times when your 'application
is busy'. Your app gets busy at Window's discretion more often than you
realize. However, you could probably detect busy status via
Application.AddMessageFilter. I advise against it.

What you could do is to set WaitCursor at the places where your app gets
'significantly' busy, and set CursorNormal in an Application.Idle event
handler. I would bookkeep your app's cursor status in a global variable so
that you can no-op attempts to set it to busy when it is already busy (or to
normal when it is already normal). You might want to set the cursor for all
forms in your app at the same time. All this suggests a sub whose calling
sequence takes a boolean busy-notbusy parameter.

Is there an other (easier) way to show an user that the application is busy
at the time ?
for example when I ask information at the database the sql server is serval
seconds busy to retrief all the data and display it to the user. I want to
make clear to the user that the application is busy at the time. so what is
the best way to do this ?

Jan
 
G

Guest

Is there an other (easier) way to show an user that the application is busy
at the time ?
for example when I ask information at the database the sql server is serval
seconds busy to retrief all the data and display it to the user. I want to
make clear to the user that the application is busy at the time. so what is
the best way to do this ?

In my opinion, WaitCursor is the best way. It is also the conventional way
in windows. You could make something up (eg a color change to your form(s)),
but it would take some effort, so my guess is that WaitCursor is the easiest
way as well.
 
C

C-Services Holland b.v.

Jan said:
"AMercer" wrote:
Is there an other (easier) way to show an user that the application is busy
at the time ?
for example when I ask information at the database the sql server is serval
seconds busy to retrief all the data and display it to the user. I want to
make clear to the user that the application is busy at the time. so what is
the best way to do this ?

Jan

We usually popup a borderless window with a message like "Please wait,
retrieving data" or something to that effect.
 
G

Guest

Is there an other (easier) way to show an user that the application is
busy
In my opinion, WaitCursor is the best way. It is also the conventional way
in windows. You could make something up (eg a color change to your form(s)),
but it would take some effort, so my guess is that WaitCursor is the easiest
way as well.

Is it correct that when I think the client could be busy and I call the
function WaitCursor that it automaticly comes back to the "normal arrow
state" or is the WaitCursor still active at the background ?

I tried somethings but when the client is ready and is back in the "normal
arrow state" I don't get the WaitCursor state. Unless I call it again. So it
seems that I only have to call WaitCursor when I think the client could be
busy and Windows does the rest and sets the cursor back to normal when the
data is retrieved.
 
G

Guest

Is it correct that when I think the client could be busy and I call the
function WaitCursor that it automaticly comes back to the "normal arrow
state" or is the WaitCursor still active at the background ?

I tried somethings but when the client is ready and is back in the "normal
arrow state" I don't get the WaitCursor state. Unless I call it again. So it
seems that I only have to call WaitCursor when I think the client could be
busy and Windows does the rest and sets the cursor back to normal when the
data is retrieved.

I set the control's .Cursor property, and I don't mess with the .Current
property, so I am on unfamiliar ground. The documentation says that if you
change .Current, and the call DoEvents, the .Current property will be
restored:

"All controls that derive from the Control class have a Cursor property. To
change the cursor displayed by the mouse pointer when it is within the bounds
of the control, assign a Cursor to the Cursor property of the control.
Alternatively, you can display cursors at the application level by assigning
a Cursor to the Current property. For example, if the purpose of your
application is to edit a text file, you might set the Current property to
Cursors.WaitCursor to display a wait cursor over the application while the
file loads or saves to prevent any mouse events from being processed. When
the process is complete, set the Current property to Cursors.Default for the
application to display the appropriate cursor over each control type.

Note If you call Application.DoEvents before resetting the Current
property back to the Cursors.Default cursor, the application will resume
listening for mouse events and will resume displaying the appropriate Cursor
for each control in the application."
 

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