views:

94

answers:

1

I have an animated Cursor file (*.ani) in the resources and want to show it as a cursor in my application. How can I load it from the resources?

I looked up in the Internet, but there are only ways to show it when u have a real file and if it is not embedded in the resources.

A: 

Embed the ani file as a resource and use windows functions CreateIconFromResource to create it and DestroyIcon when done.

IntPtr hCursor;
try
{
   hCursor = CreateIconFromResource(resource, (uint)resource.Length, false, 0x00030000);
   this.Cursor = new Cursor(hCursor);
   ...
}
finally
{
   this.Cursor = Cursors.Normal;
   DestroyIcon(hCursor);
}
ILa