如何改变鼠标样式
如何改变鼠标样式比如改变成图片心型等
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace GameLink.GameClass
{
/// <summary>
/// 自定义鼠标样式
/// 可以是彩色 动画==
/// </summary>
class MouseStyle
{
[DllImport("user32.dll")]
public static extern IntPtr LoadCursorFromFile(string filename);
[DllImport("user32.dll")]
public static extern IntPtr SetCursor(IntPtr cursorHandle);
[DllImport("user32.dll")]
public static extern uint DestroyCursor(IntPtr cursorHandle);
public MouseStyle()
{
}
public Cursor MyMouseStyle(string filename)
{
Cursor myCursor = new Cursor(Cursor.Current.Handle);
IntPtr colorCursorHandle = LoadCursorFromFile(filename);
myCursor.GetType().InvokeMember("handle", BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.SetField, null, myCursor, new object[] { colorCursorHandle });
return myCursor;
}
}
}
给你一个类你自己调用哟