鼠标移到客户区时,即变为黑色半透明

解决方案 »

  1.   

       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("myCur.png");
                SetCursor(a, new Point(0, 0));
            }
      

  2.   


    Graphics graphics = this.CreateGraphics();
    Rectangle rectangle = new Rectangle(new Point(e.X, e.Y),
                    new Size(this.Cursor.Size.Width * 2, this.Cursor.Size.Height * 2));
    this.Cursor.Draw(graphics, rectangle);这种绘制方式可以实现吗?
    还没找到如何控制graphics和rectangle实现黑色半透明呢
      

  3.   

    使用ShowCursor API,直接隐藏鼠标,然后画个黑色半透明图形跟住