How do I create a dynamic mouse cursor .NET without using interop?

前端 未结 4 933
有刺的猬
有刺的猬 2021-01-20 08:01

I have an application which I\'m interested in eventually porting to mono so I\'m trying to avoid using p/invoke\'s to accomplish this task.

I would like to load a c

4条回答
  •  清酒与你
    2021-01-20 08:39

    I was reference the post: How can i replace cursor with bitmap in winform

    You can create a Array of static cursor and use Timer to change it

    to make dynamic mouse cursor effect!

    Create static cursor from bitmap is so simply and without using interop:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
            Icon icon = this.Icon;
            Bitmap bmp = icon.ToBitmap();
            Cursor cur = new Cursor(bmp.GetHicon());
    
            this.Cursor = cur;
        }
    }
    

提交回复
热议问题