Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
4.50/5 (4 votes)
28 Dec 2010CPOL 6.8K   1   1
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)


Written By
Software Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralSergey, I will accept the alternative as a simplified form o... Pin
Sergey Alexandrovich Kryukov28-Dec-10 17:46
mvaSergey Alexandrovich Kryukov28-Dec-10 17:46 

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

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