Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

I'm setting Cursor.Current = Cursors.WaitCursor and I'm finding that sometimes it will go back to Cursors.Default before I want it to, which can be confusing for the end user.

 

I'm guess perhaps the system is setting it back when it hits an event or perhaps try and catch.. Unsure. Does anyone know what if the framework can cause the Cursor.Current to go back to Cursors.Default. Can I overcome this somehow? Can I change Cursors.Default to be Cursors.WaitCursor?

 

Thanks

 

SEVI

Posted

No ... you can't change Cursors.Default to be Cusors.WaitCursor.

 

Can I hope to see where you do your change ?

 

And if there's other change somewhere in your form... might I see them also ?

 

/** N.B. **/

I'll need to know which event is called for your change.

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

Thanks all..

 

Method() {

 

// set wait cursor

Cursor.Current = Cursors.WaitCursor;

 

Method calls to other classes..

 

// set wait cursor

Cursor.Current = Cursors.Default;

 

 

I know it makes it hard without code.. The application in question is quite large and class hops a fair bit so I can't really post much here. The method body can traverse around 6 class levels which makes it hard to solve these sorts of bugs. I was hoping there may have been some little gem of info around like .. oh yeah if a thread hits a try catch block the Cursor will back back to system default, or something..

 

SEVI

  • Administrators
Posted (edited)

Do any of the code in the other classes change the cursor? You may be unsetting it a bit too early in some situations.

 

You may want to look at a recent posting in the Code Library here

that may help - just updated it to check if the cursor has been modified in between the class setting it and unsetting it (if that makes sense)

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

You should be using an hourglass stack. Every piece of code that adds to the stack should remove from the stack. Try the following - you'll never have this problem again. I've used this approach for years and it works:

 

internal class Hourglass

{

private static int m_iHourglassCounter=0;

 

//prevent instancing by making constructor private

private Hourglass()

{

}

 

[system.Diagnostics.DebuggerHidden]

internal static void Add()

{

m_iHourglassCounter++;

Cursor.Current = Cursors.WaitCursor;

}

 

[system.Diagnostics.DebuggerHidden]

internal static void Remove()

{

m_iHourglassCounter--;

if (m_iHourglassCounter < 0)

{

//something's wrong (did a remove on its own)

System.Diagnostics.Debugger.Break();

m_iHourglassCounter = 0;

}

 

if (m_iHourglassCounter == 0)

Cursor.Current = Cursors.Default;

}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...