如何在WPF中更改鼠标光标的指向位置

Aym*_*udi 5 .net c# wpf winforms

我生成了一个.cur文件在我的WPF应用程序中使用它,默认情况下指向位置是左上角,我想将它设置为中心.

我发现这里的一些线程通过设置HotSpots 来帮助解决这个问题,你可以在这里做这样的事情:

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);
}
Run Code Online (Sandbox Code Playgroud)

问题出在WindosForms中.在WPF中,Cursor类构造函数不接受a IntPtr,它只接受a StreamString(文件路径).

我怎样才能在WPF中实现这一点,还有其他方法吗?

Aym*_*udi 0

正如 @Kami 提到的,我必须在我的 .CUR 文件上应用此线程中提到的相同逻辑,并且它有效。