Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Hourglass Mouse Cursor Always Changes Back to its Original Image. How?

, 28 Dec 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
With System.Windows.Forms it's not necessary to pass the owner. You can use static property Cursor.Current.I use the following class in my projects:public sealed class WaitCursor : IDisposable{ private Cursor _SavedCursor; public WaitCursor() { _SavedCursor =...
With System.Windows.Forms it's not necessary to pass the owner. You can use static property Cursor.Current.
 
I use the following class in my projects:
 
public sealed class WaitCursor : IDisposable
{
  private Cursor _SavedCursor;
  public WaitCursor()
  {
    _SavedCursor = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
  }
  public void Dispose()
  {
    Cursor.Current = _SavedCursor;
  }
}
Usage:
using (new WaitCursor())
{
  // do something
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SergeyT2
Software Developer
Russian Federation Russian Federation
No Biography provided

Comments and Discussions

 
GeneralSergey, I will accept the alternative as a simplified form o... PinmvpSAKryukov28-Dec-10 18:46 
Sergey, I will accept the alternative as a simplified form of my original technique. It makes sense in most cases.
 
I would rather combine them together to let the user decide to go with fine-grain technique (which can be useful if different controls normally should show different cursors) or more simple and typical case, which would be implemented simpler with your technique.
 
Thank you.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 29 Dec 2010
Article Copyright 2010 by SergeyT2
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid