我做一个winform的项目,需要改变窗体的鼠标图标,我从网上下载了一段代码
public void SetCursor(Bitmap cursor, Point hotPoint)
{
int hotX = hotPoint.X;
int hotY = hotPoint.Y;
Bitmap myNewCursor = new Bitmap(cursor.Width * 2 - hotX, cursor.Height * 2 - hotY);
Graphics g = Graphics.FromImage(myNewCursor);
g.Clear(Color.FromArgb(0, 0, 0, 0));
g.DrawImage(cursor, cursor.Width - hotX, cursor.Height - hotY, cursor.Width, cursor.Height); this.Cursor = new Cursor(myNewCursor.GetHicon()); g.Dispose();
myNewCursor.Dispose();
} private void Login_Load(object sender, EventArgs e)
{
Bitmap a = (Bitmap)Bitmap.FromFile("Images/pm.png");
SetCursor(a, new Point(0, 0)); //new Point() 定义鼠标的可用点位置。
}但是执行后窗体初始的那个箭头还存在,和我载入的图标重叠移动,不知道是为什么,怎么才能让windows默认的那个箭头隐藏掉或去掉??
public void SetCursor(Bitmap cursor, Point hotPoint)
{
int hotX = hotPoint.X;
int hotY = hotPoint.Y;
Bitmap myNewCursor = new Bitmap(cursor.Width * 2 - hotX, cursor.Height * 2 - hotY);
Graphics g = Graphics.FromImage(myNewCursor);
g.Clear(Color.FromArgb(0, 0, 0, 0));
g.DrawImage(cursor, cursor.Width - hotX, cursor.Height - hotY, cursor.Width, cursor.Height); this.Cursor = new Cursor(myNewCursor.GetHicon()); g.Dispose();
myNewCursor.Dispose();
} private void Login_Load(object sender, EventArgs e)
{
Bitmap a = (Bitmap)Bitmap.FromFile("Images/pm.png");
SetCursor(a, new Point(0, 0)); //new Point() 定义鼠标的可用点位置。
}但是执行后窗体初始的那个箭头还存在,和我载入的图标重叠移动,不知道是为什么,怎么才能让windows默认的那个箭头隐藏掉或去掉??
解决方案 »
- WebClient DownloadFile 文件不完整
- ASP.NET空间,哪里的便宜或免费?谢谢!
- 学编程,看A片。
- 判断输入的值
- 新手问下关于DataGridView和重写属性的问题高手指点下谢谢
- C# ListView....怎么让某一列出现一个下拉框??
- 注册表的问题,换个角度是enum的问题,多多帮忙,谢谢!
- 简单问题! 登录 注销 重新登录 换用户名?
- fastreport问题
- 本人新手 最近做了一个拼图游戏 但是出了一些小问题 希望能有人帮我解答一下
- VS2008 C# WM6开发TXT阅读器,关联文件后如何实现多实例(多开)?
- 软件中用语句读取ini文件中的sql语句字符,执行出错在'"之间多出\
Bitmap bitmap = new Bitmap(fn);
IntPtr handle = bitmap.GetHicon();
Cursor myCursor = new Cursor(handle);
this.Cursor = myCursor;