zoukankan      html  css  js  c++  java
  • C# winform 自定义鼠标图标

     //设置鼠标图标
                Bitmap a = (Bitmap)Bitmap.FromFile("1.png");
                SetCursor(a, new Point(16, 36)); //new Point() 定义鼠标的可用点位置。

     

      //设置鼠标函数
            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();
            }

    作者:观海看云个人开发历程知识库 - 博客园
    出处:http://www.cnblogs.com/zhangtao/
    文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    论文笔记4
    论文笔记3
    论文笔记2
    论文笔记1
    论文笔记
    AFG与AWG的比较
    Linux下“有线线缆被拔出”问题的解决
    python生成excel格式座位表
    PythonTip--一马当先--bfs
    python pygame--倒计时
  • 原文地址:https://www.cnblogs.com/zhangtao/p/2347513.html
Copyright © 2011-2022 走看看