I am creating visual studio add-in. I want to change the mouse cursor to wait while my plugin is running and set earlier mouse pointer after it finishes execution.
How to change the Cursor ?
I am creating visual studio add-in. I want to change the mouse cursor to wait while my plugin is running and set earlier mouse pointer after it finishes execution.
How to change the Cursor ?
简单的方法 :
// class for managing waiting cursor
public class WaitCursor : IDisposable
{
private Cursor previousCursor;
public WaitCursor()
{
this.previousCursor = Mouse.OverrideCursor;
Mouse.OverrideCursor = Cursors.Wait;
}
#region IDisposable Members
public void Dispose()
{
Mouse.OverrideCursor = this.previousCursor;
}
#endregion IDisposable Members
}
然后,只需使用
using (WaitCursor wait = new WaitCursor())
{
// code that will execute with wait cursor
}