SEVI Posted May 13, 2004 Posted May 13, 2004 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 Quote
Arch4ngel Posted May 13, 2004 Posted May 13, 2004 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. Quote "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
Administrators PlausiblyDamp Posted May 13, 2004 Administrators Posted May 13, 2004 Could you post the relevant code on how you are setting / un-setting the cursor? Does this problem occur in several places or just in one or two particular locations? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SEVI Posted May 13, 2004 Author Posted May 13, 2004 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 Quote
Administrators PlausiblyDamp Posted May 13, 2004 Administrators Posted May 13, 2004 (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 May 13, 2004 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jaco Posted May 13, 2004 Posted May 13, 2004 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; } } Quote
SEVI Posted May 13, 2004 Author Posted May 13, 2004 Thanks guys.. will give it a look in the morning.. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.