请问一个关于鼠标指针的问题!
请问如何设置鼠标的光标用于全局?
离开本对话框也不变,类似于SPY++那样的!
问题点数:100、回复次数:6Top
1 楼huwei001982(凶猛的小狗)回复于 2004-09-04 16:51:28 得分 50
在 LButtonDown 中先执行
SetCapture();
再设置 鼠标光标
别忘了在 LButtonUp中
ReleaseCapture();Top
2 楼sock5(|一生何求|)回复于 2004-09-04 17:04:35 得分 0
还是不行呀,这个光标无法移出对话框呀!移出后就变成系统默认的了
我是这么设置的
BOOL CClientUpdate3Dlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
if(pMsg->wParam==VK_F12)
{
MessageBox("F12");
//::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
SetCapture();
SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
}
return CDialog::PreTranslateMessage(pMsg);
}
Top
3 楼huwei001982(凶猛的小狗)回复于 2004-09-04 17:25:04 得分 47
就你上面的代码看, 你的想法就是错的
SPY++的十字光标, 也只限于一直按住鼠标左键再可以(就像我上面的代码一样), 松开就不行了
只要你的鼠标离开你的窗体, 鼠标光标就不属于你管了,虽然用 SetCapture可以强制将鼠标消
息发送到你的窗体, 但也只能在 LButtonDown中设置才可以(也就是鼠标按键必须一直按着), 具体原因我也不知道
请看 MSDN
The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window
光标是一个共享资源, 窗体只能在鼠标处于窗体的客户区时, 才可以设置它, 只要鼠标离开窗体的客户区, WINDOW将恢复以前的光标
Top
4 楼zihan(子寒)回复于 2004-09-04 17:38:02 得分 1
同意,安装楼上第一次的办法就可以做到了。Top
5 楼crystal521(【云淡风轻】)回复于 2004-09-04 20:30:49 得分 1
upTop
6 楼flyelf(空谷清音)回复于 2004-09-04 21:58:28 得分 1
在WM_LBUTTONDOWN中
获取wm_mousemove消息,设置光标Top




