I'm using GetHicon to create a Cursor from a bitmap but I'm getting a memory
leak when I do so. If I use DestroyIcon then memory leak goes away but the
newly created Cursor is invalid. Is this a known problem or am I doing
something wrong? I don't want to leak handles but I have to have my Cursor,
too. Suggestions?
After removing extra code involved in handling the hotspot issue and other
extraneous drawing things, this is the problematic code:
public Cursor MakeCursor(Bitmap bm)
{
IntPtr ptr = bm.GetHicon();
Cursor retCursor = new Cursor(ptr);
// If this line is included then returned Cursor is invalid
// If not included then Task Manager indicates handle leaks.
DestroyIcon(ptr);
return retCursor;
}
--
Richard Lewis Haggard
www.Haggard-And-Associates.com