【发布时间】:2010-01-26 21:39:41
【问题描述】:
我正在通过图标文件在我的应用程序上设置自定义光标,但点击点位于错误的坐标处。我用
设置光标SetClassLongPtr(hwnd, GCL_HCURSOR, reinterpret_cast<LONG_PTR>cursor)
其中光标是;
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
);
光标加载正常,但它的点击来自光标图像的左下角,而不是左上角。
wikipedia article on .ico files 表示热点仅在 .cur 文件上指定,而不是在 .ico 上。
编辑:澄清问题
参考:LoadImage() 和 SetClassLongPtr() 在 msdn 上。
【问题讨论】:
-
从 .ico(或者更确切地说,创建 .ico 的同一位图)创建一个 .cur 文件并加载以解决问题。不过,我宁愿不必启动另一个应用程序来进行转换。 ico 文件用作光标,只是坐标错误。肯定有办法解决这个问题。