I generated a .cur file to use in my WPF application, the default position is the upper left corner, and I want to set it to the center.
I found topics here that help solve this problem by installing HotSpot s where you can do things 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 in WindosForms. In WPF, the Cursor class constructor does not accept IntPtr ; it accepts only Stream or String (file path).
How can I achieve this in WPF and is there any other way to do this?
source share