自定义鼠标指针

/// 
/// 改变鼠标指针
/// 
/// 
/// 
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;
}

 

转载于:https://www.cnblogs.com/Mzg121584668/p/7452332.html


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部