Does anyone know how to successfully load a custom color (32 bits) cursor in C# (under XP..NET 2.0 - or NET3.0 eventually)?
All I could do using C# .Net support was loading a color cursor but ending up getting it displayed in a black and white. I found an example that manages to display the cursor in color (using GetHIcon) , but I do have a hard time making its background transparent: here is the code that creates the cursor from a image file:
// create any bitmap
Bitmap b = new Bitmap( 250,170 );
Graphics g = Graphics.FromImage ( b );
// do whatever you wish
Image img = Image.FromFile("Image.bmp"));
g.DrawImage(img, 125, 85);
// this is the trick!?
IntPtr ptr = b.GetHicon();
Cursor c = new Cursor( ptr );
// attach cursor to the form
this.Cursor = c;
I have looked all over the web .. sort of ;-) but couldn't find any compelling documentation with an example that works.
Does anyone know how to make the image transparent in the above code?
Or perhaps there is a more elegant way of doing this?
Help is greatly appreciated!
Thank you
Paolo