相关疑难解决方法(0)

在WinForms/.NET中更改光标HotSpot

我正在运行时从图像资源创建一个游标.新光标的HotSpot始终设置为16x16(32x32图像).是否可以在运行时更改HotSpot,还是需要创建.cur文件?

.net winforms

8
推荐指数
1
解决办法
5322
查看次数

如何在从图标文件生成的 Windows 光标上设置热点坐标?

我正在从图标文件在我的应用程序上设置自定义光标,但单击点位于错误的坐标处。我正在设置光标

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()

winapi icons cursor

3
推荐指数
1
解决办法
5113
查看次数

标签 统计

.net ×1

cursor ×1

icons ×1

winapi ×1

winforms ×1