你好,
可以使用自定义Cursor 来实现它。下面是一个自定义Cursor的静态类。
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
static class NativeMethods
{
public static Cursor LoadCustomCursor(string path)
{
IntPtr hCurs = LoadCursorFromFile(path);
if (hCurs == IntPtr.Zero) throw new Win32Exception();
var curs = new Cursor(hCurs);
// Note: force the cursor to own the handle so it gets released properly
var fi = typeof(Cursor).GetField("ownHandle", BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue(curs, true);
return curs;
}
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr LoadCursorFromFile(string path);
}
#用法
button1.Cursor = NativeMethods.LoadCustomCursor(@"C:\Windows\Cursors\aero_link.cur");
Best regards,
Cole Wu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.