如何更改按钮上的光标? [英] How to change the cursor on a Button?
本文介绍了如何更改按钮上的光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
static HWND btn;
HCURSOR cursor = LoadCursor(0, IDC_CROSS);
case WM_CREATE:
btn = CreateWindow(TEXT("BUTTON"), TEXT("Press Me"),
WS_CHILD|WS_VISIBLE, 50, 50, 80, 30,
hwnd, (HMENU) 111, NULL, NULL);
现在,在 WM_COMMAND
,我尝试使用:
Now, in WM_COMMAND
, I try to use:
SendMessage(btn, WM_SETCURSOR, 0, (LPARAM) cursor);
这是行不通的。
那么,如何改变鼠标的光标就点击这个按钮后?此外,如何更改鼠标光标,因为它悬停在按钮(如它悬停在网络浏览器链接时变为手)?
So how do I change the cursor of the mouse after it clicks the button? Also, how do I change the cursor of the mouse as it is hovering over the button (like it changes to a hand when hovering over links in web-browsers)?
推荐答案
使用此code改变单一控制的光标:
Use this code to change the cursor of a single control:
SetWindowLong(btn, GCL_HCURSOR, (LONG)cursor);
preferred方法,64位兼容性,方法是:
Preferred method, for 64 bit compatibility, is:
SetWindowLongPtr(btn, GCL_HCURSOR, (LONG_PTR)cursor);
这篇关于如何更改按钮上的光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文