C# Creating a Custom Mouse Cursor

    技术2022-05-11  54

    C# Creating a Custom Mouse Cursor

    Posted in Programming at 7:17 am by Michael Daniel

    This is surprisingly easy to do. To create a cursor from an image resource:

    Cursor cursor = new Cursor(Properties.Resources.add.GetHicon());this.Cursor = cursor; 

    To create a cursor from any graphic:

    Bitmap bmp = new Bitmap(55, 25);Graphics g = Graphics.FromImage(bmp);g.DrawString(“Hello World!”, this.Font, Brushes.Blue, 0, 0);Cursor cursor = new Cursor(bmp.GetHicon());this.Cursor = cursor;


    最新回复(0)