请问如何设置鼠标的光标用于全局?离开本对话框也不变,类似于SPY++那样的!

解决方案 »

  1.   

    在 LButtonDown 中先执行
    SetCapture();
    再设置 鼠标光标别忘了在 LButtonUp中
    ReleaseCapture();
      

  2.   

    还是不行呀,这个光标无法移出对话框呀!移出后就变成系统默认的了我是这么设置的
    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);
    }
      

  3.   

    就你上面的代码看, 你的想法就是错的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将恢复以前的光标
      

  4.   

    在WM_LBUTTONDOWN中
    获取wm_mousemove消息,设置光标