473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Whats's the problem using a enum like this?

If e.Button = MouseButtons.Left Then

also from a

Dim Answer As DialogResult = MessageBox.Show..

Select Case Answer

Case DialogResult.Yes

and many other uses of an enum I get

Warning 153 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated.

Why not. What's the problem using a enum like this?


Jan 27 '06 #1
18 2022
Are you sure this is one of those cases? The code you have there wouldn't
generate those types of warnings - it doesn't for me.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
If e.Button = MouseButtons.Left Then

also from a

Dim Answer As DialogResult = MessageBox.Show..

Select Case Answer

Case DialogResult.Yes

and many other uses of an enum I get

Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.

Why not. What's the problem using a enum like this?


Jan 27 '06 #2
" **Developer**" <RE*************@a-znet.com> schrieb:
If e.Button = MouseButtons.Left Then

also from a

Dim Answer As DialogResult = MessageBox.Show..

Select Case Answer

Case DialogResult.Yes

and many other uses of an enum I get

Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.


The problem is that forms have a 'DialogResult' property which shadows the
type 'DialogResult'. Either fully qualify the 'DialogResult' type
('System.Windows.Forms.DialogResult') or define a namespace alias:

\\\
Imports WinForms = System.Windows.Forms
....
If Answer = WinForms.DialogResult.OK Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 27 '06 #3
**Developer**,
In addition to the other comments.
As you may this is a new warning that is intended to let you know of
potentially confusing code, such as code like:

Dim aThread As New System.Threading.Thread(AddressOf ThreadProc)
aThread.Start()
aThread.Sleep(TimeSpan.FromSeconds(5))

Which Thread is going to sleep for 5 seconds?

Remember Thread.Sleep is a shared method that operates on the CurrentThread.
| Warning 153 Access of shared member, constant member, enum member or
nested
| type through an instance; qualifying expression will not be evaluated.
Are all 153 referring to DialogResult?

You could use "Project - Properties - Compile" to change the "Instance
variable accesses shared member" from Warning to None. However I would only
change it temporarily to simplify changing other errors & warnings. Once the
other errors & warnings are taken care of I would turn the warning back on &
address the issues...
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
| If e.Button = MouseButtons.Left Then
|
| also from a
|
| Dim Answer As DialogResult = MessageBox.Show..
|
| Select Case Answer
|
| Case DialogResult.Yes
|
| and many other uses of an enum I get
|
| Warning 153 Access of shared member, constant member, enum member or
nested
| type through an instance; qualifying expression will not be evaluated.
|
|
|
| Why not. What's the problem using a enum like this?
|
|
|
|
|
|
Jan 27 '06 #4
Thanks, I can fix it now!
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
If e.Button = MouseButtons.Left Then

also from a

Dim Answer As DialogResult = MessageBox.Show..

Select Case Answer

Case DialogResult.Yes

and many other uses of an enum I get

Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.

Why not. What's the problem using a enum like this?


Jan 27 '06 #5
Not as simple as I thought.

Many places where I set Cursor.Current I get the same message.

Consider the following sub

I get the error at each Cursor.Current

Got any more wisdom to share?

Public Shared Sub SetToWaitCursor(ByVal c As Control)

'This sub set Cursor.Current to Cursors.WaitCursor for all controls in
c.Controls - searches 3 levels

On Error Resume Next

For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C1.Controls

C3.Cursor.Current = Cursors.WaitCursor

Next C3

C1.Cursor.Current = Cursors.WaitCursor

Next C2

C1.Cursor.Current = Cursors.WaitCursor

Next C1

End Sub

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
If e.Button = MouseButtons.Left Then

also from a

Dim Answer As DialogResult = MessageBox.Show..

Select Case Answer

Case DialogResult.Yes

and many other uses of an enum I get

Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.


The problem is that forms have a 'DialogResult' property which shadows the
type 'DialogResult'. Either fully qualify the 'DialogResult' type
('System.Windows.Forms.DialogResult') or define a namespace alias:

\\\
Imports WinForms = System.Windows.Forms
...
If Answer = WinForms.DialogResult.OK Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 28 '06 #6
" **Developer**" <RE*************@a-znet.com> schrieb:
For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C1.Controls
The line above should read '... In C2.Controls', shouldn't it?
C3.Cursor.Current = Cursors.WaitCursor


=> 'C3.Cursor = Cursors.WaitCursor'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 28 '06 #7

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C1.Controls
The line above should read '... In C2.Controls', shouldn't it?

Boy! Sharp eyes.
C3.Cursor.Current = Cursors.WaitCursor
=> 'C3.Cursor = Cursors.WaitCursor'.


This a change in 2005 or was it wrong in 2003 also??

Thanks a lot


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 28 '06 #8
**Developer**
In addition to Herfried's comments:

Cursor is a property of Control, Cursor is also a type that has a shared
property of Current

| C3.Cursor.Current = Cursors.WaitCursor
| C1.Cursor.Current = Cursors.WaitCursor
^ should be C2 shouldn't it?
| C1.Cursor.Current = Cursors.WaitCursor

In the above three lines you are setting the shared property
System.Windows.Forms.Cursor.Current to Cursors.WaitCursor, you are NOT
modifying any control's Cursor property!
This a change in 2005 or was it wrong in 2003 also??

If you used this code "as is" in VB2003, then yes your code was wrong in
VB2003 also!

FWIW: This is a very good example of why the warning was added!
To modify the Cursor property of a Control, you simply:

Dim C1 As Control
C1.Cursor = Cursors.WaitCursor
You don't need the pseudo recursion.

You can simplify your routine to:

Public Shared Sub SetToWaitCursor(ByVal c As Control)
' qualify the name to avoid attempting to use the Form/Control
property
System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
End Sub

Which is effectively what you were running in VB 2003.

If you "need" the pseudo recursion, try:

For Each C1 As Control In c.Controls
For Each C2 As Control In C1.Controls
For Each C3 As Control In C2.Controls
C3.Cursor = Cursors.WaitCursor
Next C3
C2.Cursor = Cursors.WaitCursor
Next C2
C1.Cursor = Cursors.WaitCursor
Next C1
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Op****************@TK2MSFTNGP09.phx.gbl...
| Not as simple as I thought.
|
| Many places where I set Cursor.Current I get the same message.
|
| Consider the following sub
|
| I get the error at each Cursor.Current
|
| Got any more wisdom to share?
|
|
|
|
|
| Public Shared Sub SetToWaitCursor(ByVal c As Control)
|
| 'This sub set Cursor.Current to Cursors.WaitCursor for all controls in
| c.Controls - searches 3 levels
|
| On Error Resume Next
|
| For Each C1 As Control In c.Controls
|
| For Each C2 As Control In C1.Controls
|
| For Each C3 As Control In C1.Controls
|
| C3.Cursor.Current = Cursors.WaitCursor
|
| Next C3
|
| C1.Cursor.Current = Cursors.WaitCursor
|
| Next C2
|
| C1.Cursor.Current = Cursors.WaitCursor
|
| Next C1
|
| End Sub
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
| news:O8**************@TK2MSFTNGP09.phx.gbl...
| >" **Developer**" <RE*************@a-znet.com> schrieb:
| >> If e.Button = MouseButtons.Left Then
| >>
| >> also from a
| >>
| >> Dim Answer As DialogResult = MessageBox.Show..
| >>
| >> Select Case Answer
| >>
| >> Case DialogResult.Yes
| >>
| >> and many other uses of an enum I get
| >>
| >> Warning 153 Access of shared member, constant member, enum member or
| >> nested type through an instance; qualifying expression will not be
| >> evaluated.
| >
| > The problem is that forms have a 'DialogResult' property which shadows
the
| > type 'DialogResult'. Either fully qualify the 'DialogResult' type
| > ('System.Windows.Forms.DialogResult') or define a namespace alias:
| >
| > \\\
| > Imports WinForms = System.Windows.Forms
| > ...
| > If Answer = WinForms.DialogResult.OK Then
| > ...
| > End If
| > ///
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:http://dotnet.mvps.org/>
| > V B <URL:http://classicvb.org/petition/>
|
|
Jan 28 '06 #9
" **Developer**" <RE*************@a-znet.com> schrieb:
For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C1.Controls


The line above should read '... In C2.Controls', shouldn't it?

Boy! Sharp eyes.
C3.Cursor.Current = Cursors.WaitCursor


=> 'C3.Cursor = Cursors.WaitCursor'.


This a change in 2005 or was it wrong in 2003 also??


It should have been written as 'C3.Cursor = Cursors.WaitCursor' in VB.NET
2003 too. 'Cursor.Current' is something different.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 28 '06 #10
I thought Cursor.Current was used so that when you exited the method the
cursor revered to what it was when you entered or to the default - can't
remember which I thought. Don't know where I learned this (or mislearned)

Also, the cursor change is application wide - just verified this but not the
above.

Anyway, maybe it's not what I need but what is wrong with
C3.Cursor.Current = Cursors.WaitCursor
after all there is a Cursor.Current property?

Why
Warning 153 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated.

for
C3.Cursor.Current = Cursors.WaitCursor

THANKS

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C1.Controls

The line above should read '... In C2.Controls', shouldn't it?

Boy! Sharp eyes.

C3.Cursor.Current = Cursors.WaitCursor

=> 'C3.Cursor = Cursors.WaitCursor'.


This a change in 2005 or was it wrong in 2003 also??


It should have been written as 'C3.Cursor = Cursors.WaitCursor' in VB.NET
2003 too. 'Cursor.Current' is something different.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 28 '06 #11
Scratch this! I just read Jay's post
Thanks

" **Developer**" <RE*************@a-znet.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
I thought Cursor.Current was used so that when you exited the method the
cursor revered to what it was when you entered or to the default - can't
remember which I thought. Don't know where I learned this (or mislearned)

Also, the cursor change is application wide - just verified this but not
the above.

Anyway, maybe it's not what I need but what is wrong with
C3.Cursor.Current = Cursors.WaitCursor
after all there is a Cursor.Current property?

Why
Warning 153 Access of shared member, constant member, enum member or
nested
type through an instance; qualifying expression will not be evaluated.

for
C3.Cursor.Current = Cursors.WaitCursor

THANKS

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
> For Each C1 As Control In c.Controls
>
> For Each C2 As Control In C1.Controls
>
> For Each C3 As Control In C1.Controls

The line above should read '... In C2.Controls', shouldn't it?
Boy! Sharp eyes.
> C3.Cursor.Current = Cursors.WaitCursor

=> 'C3.Cursor = Cursors.WaitCursor'.

This a change in 2005 or was it wrong in 2003 also??


It should have been written as 'C3.Cursor = Cursors.WaitCursor' in VB.NET
2003 too. 'Cursor.Current' is something different.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Jan 28 '06 #12
>
If you "need" the pseudo recursion, try:

For Each C1 As Control In c.Controls
For Each C2 As Control In C1.Controls
For Each C3 As Control In C2.Controls
C3.Cursor = Cursors.WaitCursor
Next C3
C2.Cursor = Cursors.WaitCursor
Next C2
C1.Cursor = Cursors.WaitCursor
Next C1
--

Is there recursion in the above?
I believe it is called with c referencing a usercontrol that contains many
controls on it, so as to set the cursor for all of them.

Also, do I need to reset the cursor?
I think I remember a case where a Sub set the cursor, called another Sub
that also set the cursor and then reset it to default which negated the
effect of the first Sub's set.
Is this the way it works.
How to get around it?
Thanks for the help
Jan 28 '06 #13
" **Developer**" <RE*************@a-znet.com> schrieb
I thought Cursor.Current was used so that when you exited the method
the cursor revered to what it was when you entered or to the default
- can't remember which I thought. Don't know where I learned this
(or mislearned)

Also, the cursor change is application wide - just verified this but
not the above.

Anyway, maybe it's not what I need but what is wrong with
C3.Cursor.Current = Cursors.WaitCursor
after all there is a Cursor.Current property?

Why
Warning 153 Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.

for
C3.Cursor.Current = Cursors.WaitCursor


Current is a /shared/ method. You are referring to it by an object
reference. This makes the code look like it is a property of C3. It is /not/
a property of C3 because it is a /shared/ member. Therefore, you should
refer to it by the class name.

You can even change the Current property if you do not have a single
control, because the Current property is independent from any control. Both,

- C3.Cursor.Current = Cursors.WaitCursor
- System.Windows.Forms.Cursor.Current = Cursors.WaitCursor

do /exactly/ the same. There's only the problem, when you read the code,
that the first version indicates that the Current property belongs anyhow to
control C3. This is not true. Despite, the compiler knows what you mean (you
mean the 2nd version), and gives a warning only.

Armin

Jan 28 '06 #14
But does it make sense to do this (see code below) at all.
I call it with c referencing a usercontrol so as to set the cursor for all
the controls on the usercontrol.
I mean - is there a better way?

Do I have to reset all the cursors to default when I'm done (it's not
automatically done is it?)
=====

Also ( I wrote this in another post) I believe I have an instance where a
sub sets the cursor, call another sub which also sets the cursor and it then
resets it before returning and before the first sub wants it reset.

How do I get around that?
Public Shared Sub SetToWaitCursor(ByVal c As Control)

'This sub sets Cursor to Cursors.WaitCursor for all controls in
c.Controls - searches 3 levels

On Error Resume Next

For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C2.Controls

C3.Cursor = Cursors.WaitCursor

Next C3

C1.Cursor = Cursors.WaitCursor

Next C2

C1.Cursor = Cursors.WaitCursor

Next C1

End Sub


- C3.Cursor.Current = Cursors.WaitCursor
- System.Windows.Forms.Cursor.Current = Cursors.WaitCursor

do /exactly/ the same.


because it is Shared - I think I've got it - thanks
And the first one produces the warning message because it's confusing way of
doing it
Jan 28 '06 #15
" **Developer**" <RE*************@a-znet.com> schrieb
But does it make sense to do this (see code below) at all.
I call it with c referencing a usercontrol so as to set the cursor
for all the controls on the usercontrol.
I mean - is there a better way?
I didn't follow the whole thread, so maybe it's already been mentioned:

You first have to determine what you want the cursor to indicate:

If the user can not operate the UI, you can set the Current property of the
Cursor class to the WaitCursor. I don't see why you would ever want to set
the WaitCursor for each single control. If the user has to wait, he has to
wait, no matter where the cursor is located. After an action has been done,
set Cursor.Current back to Cursors.Default.

Do I have to reset all the cursors to default when I'm done (it's
not automatically done is it?)
If the user can operate the UI, set the cursor just like you want. If you
need to set the cursor of the contained controls also, the loops below (or a
recursive sub) probably work. The cursor is not set back automatically. You
have to do it also. But again, I think setting a WaitCursor for controls
doesn't make sense, IMO.
=====

Also ( I wrote this in another post) I believe I have an instance
where a sub sets the cursor, call another sub which also sets the
cursor and it then resets it before returning and before the first
sub wants it reset.

How do I get around that?
Public Shared Sub SetToWaitCursor(ByVal c As Control)

'This sub sets Cursor to Cursors.WaitCursor for all controls in
c.Controls - searches 3 levels

On Error Resume Next

For Each C1 As Control In c.Controls

For Each C2 As Control In C1.Controls

For Each C3 As Control In C2.Controls

C3.Cursor = Cursors.WaitCursor

Next C3

C1.Cursor = Cursors.WaitCursor

Next C2

C1.Cursor = Cursors.WaitCursor

Next C1

End Sub

Armin

Jan 28 '06 #16

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb
But does it make sense to do this (see code below) at all.
I call it with c referencing a usercontrol so as to set the cursor
for all the controls on the usercontrol.
I mean - is there a better way?


I didn't follow the whole thread, so maybe it's already been mentioned:

You first have to determine what you want the cursor to indicate:

If the user can not operate the UI, you can set the Current property of
the
Cursor class to the WaitCursor. I don't see why you would ever want to set
the WaitCursor for each single control. If the user has to wait, he has to
wait, no matter where the cursor is located. After an action has been
done,
set Cursor.Current back to Cursors.Default.

Do I have to reset all the cursors to default when I'm done (it's
not automatically done is it?)


If the user can operate the UI, set the cursor just like you want. If you
need to set the cursor of the contained controls also, the loops below (or
a recursive sub) probably work. The cursor is not set back automatically.
You have to do it also. But again, I think setting a WaitCursor for
controls doesn't make sense, IMO.

I believe you're correct. What I need to do is
set the Current property of the Cursor class to the WaitCursor
just took awhile to realize it!

Thanks
Jan 28 '06 #17
| Is there recursion in the above?
Yes, but it may not be obvious...

You could have written your routine as:

Public Shared Sub SetToWaitCursor(ByVal c As Control)
For Each C1 As Control In c.Controls
SetToWaitCursor(C1)
C1.Cursor = Cursors.WaitCursor
Next C1
End Sub

You simply physically nested the call to self & limited it to 3 levels. I
suspect your form has many more then 3 levels of controls!

| Also, do I need to reset the cursor?
Yes.

Which is why, rather then change a control's cursor I normally change
System.Windows.Forms.Cursor, in VS.NET 2005, I use the following class:

'
' Copyright © 2005, Jay B. Harlow, All Rights Reserved.
'
Option Strict On
Option Explicit On

Public Class WaitCursor
Implements IDisposable

Private ReadOnly m_previous As Cursor
Private ReadOnly m_newCursor As Cursor

Public Sub New()
MyClass.New(Cursors.WaitCursor)
End Sub

Public Sub New(ByVal newCursor As Cursor)
If newCursor Is Nothing Then Throw New
ArgumentNullException("newCursor")
m_previous = Cursor.Current
m_newCursor = newCursor
Cursor.Current = m_newCursor
End Sub

Public Sub Restore()
Cursor.Current = m_newCursor
End Sub

Public Sub Dispose() Implements IDisposable.Dispose
Cursor.Current = m_previous
End Sub

End Class

To use it I simply:

Using wc As New WaitCursor()
' do work here
End Using

Using will automatically call the WaitCursor.Dispose method that reverts the
cursor to what it was. You can use the overload New if you want a cursor
other then a WaitCursor...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
| >
| > If you "need" the pseudo recursion, try:
| >
| > For Each C1 As Control In c.Controls
| > For Each C2 As Control In C1.Controls
| > For Each C3 As Control In C2.Controls
| > C3.Cursor = Cursors.WaitCursor
| > Next C3
| > C2.Cursor = Cursors.WaitCursor
| > Next C2
| > C1.Cursor = Cursors.WaitCursor
| > Next C1
| >
| >
| > --
| Is there recursion in the above?
| I believe it is called with c referencing a usercontrol that contains many
| controls on it, so as to set the cursor for all of them.
|
| Also, do I need to reset the cursor?
| I think I remember a case where a Sub set the cursor, called another Sub
| that also set the cursor and then reset it to default which negated the
| effect of the first Sub's set.
| Is this the way it works.
| How to get around it?
|
|
| Thanks for the help
|
|
Jan 28 '06 #18
Thanks for spending so much time on this.
I'll have to study what you show below!
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:uf**************@TK2MSFTNGP09.phx.gbl...
| Is there recursion in the above?
Yes, but it may not be obvious...

You could have written your routine as:

Public Shared Sub SetToWaitCursor(ByVal c As Control)
For Each C1 As Control In c.Controls
SetToWaitCursor(C1)
C1.Cursor = Cursors.WaitCursor
Next C1
End Sub

You simply physically nested the call to self & limited it to 3 levels. I
suspect your form has many more then 3 levels of controls!

| Also, do I need to reset the cursor?
Yes.

Which is why, rather then change a control's cursor I normally change
System.Windows.Forms.Cursor, in VS.NET 2005, I use the following class:

'
' Copyright © 2005, Jay B. Harlow, All Rights Reserved.
'
Option Strict On
Option Explicit On

Public Class WaitCursor
Implements IDisposable

Private ReadOnly m_previous As Cursor
Private ReadOnly m_newCursor As Cursor

Public Sub New()
MyClass.New(Cursors.WaitCursor)
End Sub

Public Sub New(ByVal newCursor As Cursor)
If newCursor Is Nothing Then Throw New
ArgumentNullException("newCursor")
m_previous = Cursor.Current
m_newCursor = newCursor
Cursor.Current = m_newCursor
End Sub

Public Sub Restore()
Cursor.Current = m_newCursor
End Sub

Public Sub Dispose() Implements IDisposable.Dispose
Cursor.Current = m_previous
End Sub

End Class

To use it I simply:

Using wc As New WaitCursor()
' do work here
End Using

Using will automatically call the WaitCursor.Dispose method that reverts
the
cursor to what it was. You can use the overload New if you want a cursor
other then a WaitCursor...

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
| >
| > If you "need" the pseudo recursion, try:
| >
| > For Each C1 As Control In c.Controls
| > For Each C2 As Control In C1.Controls
| > For Each C3 As Control In C2.Controls
| > C3.Cursor = Cursors.WaitCursor
| > Next C3
| > C2.Cursor = Cursors.WaitCursor
| > Next C2
| > C1.Cursor = Cursors.WaitCursor
| > Next C1
| >
| >
| > --
| Is there recursion in the above?
| I believe it is called with c referencing a usercontrol that contains
many
| controls on it, so as to set the cursor for all of them.
|
| Also, do I need to reset the cursor?
| I think I remember a case where a Sub set the cursor, called another Sub
| that also set the cursor and then reset it to default which negated the
| effect of the first Sub's set.
| Is this the way it works.
| How to get around it?
|
|
| Thanks for the help
|
|

Jan 29 '06 #19

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

Similar topics

3
by: BCC | last post by:
I have a simple container class with an enum: class MyObject { typedef enum { etype1, etype2 } EType; }; In another class I have a vector:
43
by: Mr.Tickle | last post by:
// Run this code and look for his obvious error by the compiler namespace FlagCheck { using System; enum SomeFlags {
6
by: Fao | last post by:
Hi, I am in my first year of C++ in college and my professor wants me to Write a Program with multiple functions,to input two sets of user-defined data types: One type named 'Sign' declared by...
5
by: JJ | last post by:
Hi all, whats wrong with the following code: DateTime calcDate = new DateTime(); DateTime dDate = DateTime.Now; if (calcDate.DayOfWeek(dDate) != "Saturday") || (calcDate.DayOfWeek(dDate)...
4
by: Sueffel | last post by:
What is the difference between these two statements? Dim OutData() as Byte Dim OutData as () I'm not seeing it... -- Thanks Sueffel
13
by: =?Utf-8?B?VGVycnk=?= | last post by:
I know that this is just a warning message, but I wonder why the IDE flags the first function with a warning, but not the second one. The warning message is : Function 'GetView' doesn't return a...
2
by: muddasirmunir | last post by:
i want to stop and play server server 2000 using vb6. for this i got one function on internet which is Option Explicit Public Enum ServiceState et_Stop et_Pause et_Start End Enum
7
by: Rohit | last post by:
Hi, I am working on a switch module which after reading voltage through a port pin and caterogizing it into three ranges(open,low or high), passes this range to a function switch_status() with...
13
by: Rohit | last post by:
Is there any way by which I can find number of elements in an enum list? Generally I use one last element at the end to find out total number of elements. e.g. typedef enum{ SUN, MON, TUE,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.