简体   繁体   中英

Change Cursor in Visual studio addin

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 ?

Easy way :

// 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
}

and then, simply use

using (WaitCursor wait = new WaitCursor())
{
    // code that will execute with wait cursor
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM