I generated a .cur
file to use it in my WPF
application, the pointing position by default is left top corner, and I want to set it to the center.
I found some threads here that help resolve that problem by setting the HotSpot
s, where you can do stuff like this :
public static Cursor CreateCursorNoResize(Bitmap bmp, int xHotSpot, int yHotSpot)
{
IntPtr ptr = bmp.GetHicon();
IconInfo tmp = new IconInfo();
GetIconInfo(ptr, ref tmp);
tmp.xHotspot = xHotSpot;
tmp.yHotspot = yHotSpot;
tmp.fIcon = false;
ptr = CreateIconIndirect(ref tmp);
return new Cursor(ptr);
}
The problem is that is in WindosForms. In WPF the Cursor class constructor doesn't accept a IntPtr
, it accepts only a Stream
or String
(file path).
How can I achieve this in WPF and is there a whole other way to do it ??