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 Form1_Load(object sender, EventArgs e)
        {
             //传入鼠标自定义位图
            Bitmap a = (Bitmap)Bitmap.FromFile("锤子.png");
           //调用函数
            SetCursor(a, new Point(0, 0));
        }

          ----来自凌波小屋的笔记

posted on 2015-08-19 15:42  凌波小屋  阅读(2159)  评论(0编辑  收藏  举报