码迷,mamicode.com
首页 > 其他好文 > 详细

自定义鼠标指针

时间:2017-08-30 13:07:32      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:cursor   isp   hicon   param   oid   eth   this   summary   mfile   

/// <summary>
/// 改变鼠标指针
/// </summary>
/// <param name="cursor"></param>
/// <param name="hotPoint"></param>
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-21, cursor.Width, cursor.Height);
this.Cursor = new Cursor(myNewCursor.GetHicon());
g.Dispose();
myNewCursor.Dispose();
}

private void pic_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Bitmap bm = (Bitmap)Bitmap.FromFile("钢笔2_03.png");
SetCursor(bm, new Point(0, 0));
}
}

private void pic_MouseUp(object sender, MouseEventArgs e)
{
Cursor = Cursors.Default;
}

自定义鼠标指针

标签:cursor   isp   hicon   param   oid   eth   this   summary   mfile   

原文地址:http://www.cnblogs.com/Mzg121584668/p/7452332.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!