我正在运行时从图像资源创建一个游标.新光标的HotSpot始终设置为16x16(32x32图像).是否可以在运行时更改HotSpot,还是需要创建.cur文件?
我正在从图标文件在我的应用程序上设置自定义光标,但单击点位于错误的坐标处。我正在设置光标
SetClassLongPtr(hwnd, GCL_HCURSOR, reinterpret_cast<LONG_PTR>cursor)
Run Code Online (Sandbox Code Playgroud)
其中光标是以下结果;
LoadImage(
NULL,
"some_path/cursor.ico",
IMAGE_ICON, //also tried IMAGE_CURSOR
0, //width. 0 uses the width of the file provided
0, //height. 0 uses the height of the file provided
LR_LOADFROMFILE
);
Run Code Online (Sandbox Code Playgroud)
光标加载良好,但其点击来自光标图像的左下角,而不是左上角。
这百科关于 .ico 文件的文章表示,热点仅在 .cur 文件上指定,而不是在 .ico 上指定。
编辑:澄清问题
参考: msdn 上的LoadImage()和SetClassLongPtr()。