473,545 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confused obout setting a Cursor

What are the different effects of the following two statements:

C1.Cursor = Cursors.WaitCur sor

C1.Cursor.Curre nt = Cursors.WaitCur sor

I believe the first replaces the entire C1.Cursor object with a new one
while the second only replaces the Current object of C1.Cursor, but I can't
figure when to use which.

Thanks for any help!
Nov 4 '06 #1
7 6172
Hi,

If C1 is an instance of a Control:
C1.Cursor = Cursors.WaitCur sor
This will set the cursor to be the Window's WaitCursor (usually an hour glass)
when the mouse is within the boundaries of the Control and any of its children
C1.Cursor.Curre nt = Cursors.WaitCur sor
This will not compile in C#. Cursor.Current is a static property and cannot
be accessed through an instance of a Cursor object. When set, the current
cursor being displayed is supposedly changed, according to the MSDN docs, but
it seems to be reverted back to Cursors.Default immediately in my testing.

--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ub******** ******@TK2MSFTN GP04.phx.gbl...
What are the different effects of the following two statements:

C1.Cursor = Cursors.WaitCur sor

C1.Cursor.Curre nt = Cursors.WaitCur sor

I believe the first replaces the entire C1.Cursor object with a new one
while the second only replaces the Current object of C1.Cursor, but I can't
figure when to use which.

Thanks for any help!


Nov 4 '06 #2

If you're in some method that will take a while do you set Cursor or
Current?
Just before you leave the method do you reset to Default or is that
automatic?
Thanks for the help
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OY******** ******@TK2MSFTN GP04.phx.gbl...
Hi,

If C1 is an instance of a Control:
>C1.Cursor = Cursors.WaitCur sor

This will set the cursor to be the Window's WaitCursor (usually an hour
glass) when the mouse is within the boundaries of the Control and any of
its children
>C1.Cursor.Curr ent = Cursors.WaitCur sor

This will not compile in C#. Cursor.Current is a static property and
cannot

bad example. should be

System.Windows. Forms.Cursor.Cu rrent

be accessed through an instance of a Cursor object. When set, the current
cursor being displayed is supposedly changed, according to the MSDN docs,
but it seems to be reverted back to Cursors.Default immediately in my
testing.

Before leaving the routine the setting is in?

>
--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ub******** ******@TK2MSFTN GP04.phx.gbl...
>What are the different effects of the following two statements:

C1.Cursor = Cursors.WaitCur sor

C1.Cursor.Curr ent = Cursors.WaitCur sor

I believe the first replaces the entire C1.Cursor object with a new one
while the second only replaces the Current object of C1.Cursor, but I
can't figure when to use which.

Thanks for any help!



Nov 4 '06 #3
Hi,
If you're in some method that will take a while do you set Cursor or
Current?
Setting Cursor.Current doesn't seem to do anything so I wouldn't recommend
using it at all.

If you're going to be processing some long-running task then you should be
doing that on a thread other than the UI thread (see BackgroundWorke r class).

If you want to display a WaitCursor for every Form in your application then
set Application.Use WaitCursor = true, or you can set UseWaitCursor on any
particular Control, including Forms.

In many cases you must also disable parts of the UI in code as well as setting
the WaitCursor. e.g., Control.Enabled = false and Form.Enabled = false.
Just before you leave the method do you reset to Default or is that
automatic?
In the "RunWorkerCompl eted" event handler for the BackgroundWorke r class you
should reset the cursor to Cursors.Default or just set UseWaitCursor = false
(the simpler of the two choices but it only works when you originally set
UseWaitCursor = true).

--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ug******** ******@TK2MSFTN GP03.phx.gbl...
>
If you're in some method that will take a while do you set Cursor or
Current?
Just before you leave the method do you reset to Default or is that
automatic?
Thanks for the help
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OY******** ******@TK2MSFTN GP04.phx.gbl...
>Hi,

If C1 is an instance of a Control:
>>C1.Cursor = Cursors.WaitCur sor

This will set the cursor to be the Window's WaitCursor (usually an hour
glass) when the mouse is within the boundaries of the Control and any of
its children
>>C1.Cursor.Cur rent = Cursors.WaitCur sor

This will not compile in C#. Cursor.Current is a static property and
cannot


bad example. should be

System.Windows. Forms.Cursor.Cu rrent

>be accessed through an instance of a Cursor object. When set, the current
cursor being displayed is supposedly changed, according to the MSDN docs,
but it seems to be reverted back to Cursors.Default immediately in my
testing.


Before leaving the routine the setting is in?

>>
--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ub******* *******@TK2MSFT NGP04.phx.gbl.. .
>>What are the different effects of the following two statements:

C1.Cursor = Cursors.WaitCur sor

C1.Cursor.Cur rent = Cursors.WaitCur sor

I believe the first replaces the entire C1.Cursor object with a new one
while the second only replaces the Current object of C1.Cursor, but I
can't figure when to use which.

Thanks for any help!




Nov 4 '06 #4

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:us******** ******@TK2MSFTN GP03.phx.gbl...
Hi,
>If you're in some method that will take a while do you set Cursor or
Current?

Setting Cursor.Current doesn't seem to do anything so I wouldn't recommend
using it at all.

If you're going to be processing some long-running task then you should be
doing that on a thread other than the UI thread (see BackgroundWorke r
class).

If you want to display a WaitCursor for every Form in your application
then set Application.Use WaitCursor = true, or you can set UseWaitCursor on
any particular Control, including Forms.

I had just found the Application.Use WaitCursor in Help.
It said what happens when you set it to true (all open form get set to true)
but not what happens when you set it to false.

I'm thinking about nested routines all setting it to true. Then the
innermost routine sets it to false.
Since it is boolean I'd guess the cursor gets reset on all open forms even
tho some routines are not finished.
and that this is something one must make sure does not happen.
Correct?

Actually as I think about it one has the same problem setting Forms.Cursor.
Correct?
>
In many cases you must also disable parts of the UI in code as well as
setting the WaitCursor. e.g., Control.Enabled = false and Form.Enabled =
false.
>Just before you leave the method do you reset to Default or is that
automatic?

In the "RunWorkerCompl eted" event handler for the BackgroundWorke r class
you should reset the cursor to Cursors.Default or just set UseWaitCursor =
false (the simpler of the two choices but it only works when you
originally set UseWaitCursor = true).

--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ug******** ******@TK2MSFTN GP03.phx.gbl...
>>
If you're in some method that will take a while do you set Cursor or
Current?
Just before you leave the method do you reset to Default or is that
automatic?
Thanks for the help
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OY******* *******@TK2MSFT NGP04.phx.gbl.. .
>>Hi,

If C1 is an instance of a Control:

C1.Cursor = Cursors.WaitCur sor

This will set the cursor to be the Window's WaitCursor (usually an hour
glass) when the mouse is within the boundaries of the Control and any of
its children

C1.Cursor.Cu rrent = Cursors.WaitCur sor

This will not compile in C#. Cursor.Current is a static property and
cannot


bad example. should be

System.Windows .Forms.Cursor.C urrent

>>be accessed through an instance of a Cursor object. When set, the
current cursor being displayed is supposedly changed, according to the
MSDN docs, but it seems to be reverted back to Cursors.Default
immediately in my testing.


Before leaving the routine the setting is in?

>>>
--
Dave Sexton

" Academic" <ac************ @a-znet.comwrote in message
news:ub****** ********@TK2MSF TNGP04.phx.gbl. ..
What are the different effects of the following two statements:

C1.Cursor = Cursors.WaitCur sor

C1.Cursor.Cu rrent = Cursors.WaitCur sor

I believe the first replaces the entire C1.Cursor object with a new one
while the second only replaces the Current object of C1.Cursor, but I
can't figure when to use which.

Thanks for any help!




Nov 4 '06 #5
Hi,

<snip>
I'm thinking about nested routines all setting it to true. Then the
innermost routine sets it to false.
I prefer that the UI thread handles the cursor logic and the "routines" just
process the business logic. Therefore, it's more common that the "outer"
routine sets the UseWaitCursor property to true before any of the asynchronous
processes are started and false after the entire operation is completed,
including all sub-routines that are being processed asynchronously. This, of
course, only applies to cases where you really can't allow the user to
interact with the all or part of the UI while the processing is taking place.
In some cases unrestricted user-interaction isn't a problem.
Since it is boolean I'd guess the cursor gets reset on all open forms even
tho some routines are not finished.
When UseWaitCursor is set to true before all of the operations are complete,
yes. Try it yourself to verify.
and that this is something one must make sure does not happen.
Correct?
If you allow sub-rountines to control the cursor logic then yes, you may run
into problems when one process sets UseWaitCursor to false while another
asynchronous process hasn't completed yet. You can prevent this by processing
all UI-related logic on the UI thread only, as I suggested above.
Actually as I think about it one has the same problem setting Forms.Cursor.
Correct?
Yes.

--
Dave Sexton

Nov 4 '06 #6
Hi,

Correction:

When UseWaitCursor is set to FALSE before all of the operations are complete,
yes. Try it yourself to verify.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uW******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

<snip>
>I'm thinking about nested routines all setting it to true. Then the
innermost routine sets it to false.

I prefer that the UI thread handles the cursor logic and the "routines" just
process the business logic. Therefore, it's more common that the "outer"
routine sets the UseWaitCursor property to true before any of the
asynchronous processes are started and false after the entire operation is
completed, including all sub-routines that are being processed
asynchronously. This, of course, only applies to cases where you really
can't allow the user to interact with the all or part of the UI while the
processing is taking place. In some cases unrestricted user-interaction
isn't a problem.
>Since it is boolean I'd guess the cursor gets reset on all open forms even
tho some routines are not finished.

When UseWaitCursor is set to true before all of the operations are complete,
yes. Try it yourself to verify.
>and that this is something one must make sure does not happen.
Correct?

If you allow sub-rountines to control the cursor logic then yes, you may run
into problems when one process sets UseWaitCursor to false while another
asynchronous process hasn't completed yet. You can prevent this by
processing all UI-related logic on the UI thread only, as I suggested above.
>Actually as I think about it one has the same problem setting Forms.Cursor.
Correct?

Yes.

--
Dave Sexton

Nov 4 '06 #7
Thanks for taking so much time to explain.

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:u%******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,

Correction:

When UseWaitCursor is set to FALSE before all of the operations are
complete, yes. Try it yourself to verify.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uW******** ******@TK2MSFTN GP03.phx.gbl...
>Hi,

<snip>
>>I'm thinking about nested routines all setting it to true. Then the
innermost routine sets it to false.

I prefer that the UI thread handles the cursor logic and the "routines"
just process the business logic. Therefore, it's more common that the
"outer" routine sets the UseWaitCursor property to true before any of the
asynchronous processes are started and false after the entire operation
is completed, including all sub-routines that are being processed
asynchronously . This, of course, only applies to cases where you really
can't allow the user to interact with the all or part of the UI while the
processing is taking place. In some cases unrestricted user-interaction
isn't a problem.
>>Since it is boolean I'd guess the cursor gets reset on all open forms
even tho some routines are not finished.

When UseWaitCursor is set to true before all of the operations are
complete, yes. Try it yourself to verify.
>>and that this is something one must make sure does not happen.
Correct?

If you allow sub-rountines to control the cursor logic then yes, you may
run into problems when one process sets UseWaitCursor to false while
another asynchronous process hasn't completed yet. You can prevent this
by processing all UI-related logic on the UI thread only, as I suggested
above.
>>Actually as I think about it one has the same problem setting
Forms.Curso r.
Correct?

Yes.

--
Dave Sexton


Nov 4 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3357
by: | last post by:
Hi, I am loading some crystal reports in a method similar to this (see below). And set the cursor to waiting while the reoprt is loaded, run and shown. BUT while the report is running the cursor changes back to default. I have tested setting it back to waiting after the call to run the report, - and it does get set. Has anyone else seen...
2
4304
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put there? What about Drag/Drop; is there more than one way for the source to make data available Is it always OLE?
1
3248
by: nicholas | last post by:
I am using Obout TreeView: www.obout.com I would like to implement a page to add and remove categories to a product with the Obout Treeview with checkboxes. Does anyone allready did this and could help me with this?? Here is what I would like to do: -------------------------------- When the user selects a product, he can edit the...
3
2058
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as forecolor, backcolor and font. The labels also are rotatable and the text can also be flipped 180 degrees (the flipped text part is still being worked...
0
2672
by: Netter | last post by:
I'm confused about: System.Windows.Forms.Cursor.Current = Cursors.WaitCursor Seems I read in this NG that it is not necessary to reset Cursor.Current because it gets reset automatically. Maybe when the sub is exited. Is that correct? If not, do I have to store the original value in order to reset it?
12
4989
by: info | last post by:
Hi All, I am trying to set the hourglass cursor inside a class that has nothing to do with MainForm class and I don't want to pass a reference to MainForm. How can I set the current cursor to Hourglass and then back to arrow? Thanks a lot,
1
3340
by: quantass | last post by:
Just a quick question in regards to the Obout Tree View. How do i go about adjusting the horizontal spacing before & after the plus/minus button for each node seperately? Also how do i adjust the vertical spacing for each node seperately? Thanks.
4
6551
by: David Veeneman | last post by:
I'm creating a UserControl that uses a LinkLabel. For reasons that I won't bore everyone with, I don't want the LinkLable to show the default hand cursor when the mouse enters the control. Should be a simple setting on the LinkLabel.Cursor property, right? Not so simple. I set the property, but still got the default 'hand' cursor. To debug,...
0
1015
by: jc | last post by:
Hi there: I wish to how if someone has tried (in production) OBOUT suite (http:// www.obout.com/), if is good, unstable,slow or if there are better options. At least i don't find any trouble using the sample codes. Thanks.
0
7467
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7756
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5326
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.