C#如何修改桌面上鼠标指针形状
运行c#开发的程序,修改可以修改桌面上的鼠标指针的形状,例如从箭头改成等待形状。注意:是通过写代码修改哦,而不是控制面板的修改入口。谢谢!...
运行c#开发的程序,修改可以修改桌面上的鼠标指针的形状,例如从箭头改成等待形状。
注意:是通过写代码修改哦,而不是控制面板的修改入口。
谢谢! 展开
注意:是通过写代码修改哦,而不是控制面板的修改入口。
谢谢! 展开
2015-07-16 · 知道合伙人软件行家
关注
展开全部
[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);
[DllImport("user32.dll")]
static extern IntPtr SetCursor(IntPtr hCursor);
[DllImport("user32.dll")]
static extern bool SetSystemCursor(IntPtr hcur, uint id);
private const uint OCR_NORMAL = 32512;
static Cursor ColoredCursor;
//==========C# Only
//========SET WINDOWS CURSOR========================================
IntPtr cursor = LoadCursorFromFile("example.cur");
bool ret_val = SetSystemCursor(cursor, OCR_NORMAL);
//========SET WINDOWS CURSOR========================================
//========SET FORM CURSOR========================================
IntPtr cursor = LoadCursorFromFile("example.cur");
ColoredCursor = new Cursor(cursor);
this.Cursor = ColoredCursor;
//========SET FORM CURSOR========================================
//========SET FORM CURSOR FROM IMAGE========================================
Bitmap hh = (Bitmap)System.Drawing.Bitmap.FromFile("example.png");
Graphics.FromImage(hh);
IntPtr ptr = hh.GetHicon();
Cursor c = new Cursor(ptr);
this.Cursor = c;
//========SET FORM CURSOR FROM IMAGE========================================
static extern IntPtr LoadCursorFromFile(string lpFileName);
[DllImport("user32.dll")]
static extern IntPtr SetCursor(IntPtr hCursor);
[DllImport("user32.dll")]
static extern bool SetSystemCursor(IntPtr hcur, uint id);
private const uint OCR_NORMAL = 32512;
static Cursor ColoredCursor;
//==========C# Only
//========SET WINDOWS CURSOR========================================
IntPtr cursor = LoadCursorFromFile("example.cur");
bool ret_val = SetSystemCursor(cursor, OCR_NORMAL);
//========SET WINDOWS CURSOR========================================
//========SET FORM CURSOR========================================
IntPtr cursor = LoadCursorFromFile("example.cur");
ColoredCursor = new Cursor(cursor);
this.Cursor = ColoredCursor;
//========SET FORM CURSOR========================================
//========SET FORM CURSOR FROM IMAGE========================================
Bitmap hh = (Bitmap)System.Drawing.Bitmap.FromFile("example.png");
Graphics.FromImage(hh);
IntPtr ptr = hh.GetHicon();
Cursor c = new Cursor(ptr);
this.Cursor = c;
//========SET FORM CURSOR FROM IMAGE========================================
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询