【问题标题】:Use custom cursor instead of wait cursor (hourglasses) for WinForms application对 WinForms 应用程序使用自定义光标而不是等待光标(沙漏)
【发布时间】:2018-06-08 02:31:52
【问题描述】:

我为我的 WinForms 应用程序使用自己的光标;类看起来像

public class WaitCursor : IDisposable
{
    private readonly Cursor _previousCursor;
    private static Cursor CursorResource
    {
        get
        {
            // get custom cursor from resources here
        }
    }

    private WaitCursor()
    {
        _previousCursor = Cursor.Current;
        Cursor.Current = CursorResource;
    }

    public void Dispose()
    {
        Cursor.Current = _previousCursor;
    }
}

现在我使用它时效果很好。

但是有没有办法为整个应用程序用这个覆盖系统等待光标?

我发现可以使用覆盖系统等待光标

[DllImport("user32.dll")]
static extern bool SetSystemCursor(IntPtr hcur, uint id);

是否只有应用程序级别的相同技巧?

【问题讨论】:

  • 不,没有这种技巧。

标签: c# winforms mouse-cursor


【解决方案1】:

我没有探究,但是如果你设置Cursor.Current属性并设置Application.UseWaitCursor,那么你会得到你想要的。

此外,您可以查看以下示例: http://www.blackbeltcoder.com/Articles/winforms/implementing-a-waitcursor-class

【讨论】:

    猜你喜欢
    • 2011-02-17
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    相关资源
    最近更新 更多