相应WM_SETCURSOR消息,在这里面设置光标.
否则请你在PreCreateWindow中修改Window的Class,将窗口的光标设为NULL

解决方案 »

  1.   

    在OnSetCursor()中写上对应的代码,
      

  2.   

    是在OnSetCursor里写代码,可是那些参数是怎么设置的呢,
    比如想在(200,200)至(400,400)之间采用我指定的光标,我该
    怎么做呢?
      

  3.   

    是在OnSetCursor里写代码,可是那些参数是怎么设置的呢,
    比如想在(200,200)至(400,400)之间采用我指定的光标,我该
    怎么做呢?
      

  4.   

    老兄,LoadCursor和SetCursor确实不灵,我也曾经遇到过这样的问题.你必须用全局函数.即   ::LoadCursor(),::SetCursor(),参数与LoadCursor和SetCursor有点区别,自己查一查msdn吧!至于你说在不同的位置显示不同的光标,我没有做过,不过我印象中记得好象OnSetCursor好象有一个参数表示位置,但愿是这样,记不清了......如果不是这样,你只有通过GetClientRect获得控件或者视图的大小,然后再想办法得到鼠标的位置判断......比较烦琐.写了这么多,但愿对你有帮助.
      

  5.   

    void CMonitorDialog::OnMouseMove(UINT nFlags, CPoint point) 
    {
    HCURSOR newIcon;
    CRect rect;
    GetClientRect(&rect);
    int x,y;
    x=point.x;
    y=point.y;
             if(y<200)
                {
                  newIcon=::LoadCursor(AfxGetInstanceHandle(),
                            MAKEINTRESOURCE(IDC_MOVEUP));
    ::SetCursor(newIcon);
        }
                if(y>=200)
                {
                  newIcon=::LoadCursor(AfxGetInstanceHandle(),
                            MAKEINTRESOURCE(IDC_MOVEDOWN));
    ::SetCursor(newIcon);
        } CDialog::OnMouseMove(nFlags, point);
    }我就简化成这样做,结果也不行,经常是进去的时候全屏都是上箭头,而下
    一次进去时全屏都是下箭头,真搞不懂啊
      

  6.   

    void CMonitorDialog::OnMouseMove(UINT nFlags, CPoint point) 

    HCURSOR newIcon; 
    CRect rect; 
    GetClientRect(&rect); 
    int x,y; 
    x=point.x; 
    y=point.y; 
    if(y<200) 

    newIcon=::LoadCursor(AfxGetInstanceHandle(), 
    MAKEINTRESOURCE(IDC_MOVEUP)); 
    ::SetCursor(newIcon); 

    if(y>=200) 

    newIcon=::LoadCursor(AfxGetInstanceHandle(), 
    MAKEINTRESOURCE(IDC_MOVEDOWN)); 
    ::SetCursor(newIcon); 
    } CDialog::OnMouseMove(nFlags, point); 
    } 我就简化成这样做,结果也不行,经常是进去的时候全屏都是上箭头,而下 
    一次进去时全屏都是下箭头,真搞不懂啊 
      

  7.   

    当然会出现这种情况,
    应为MouseMove消息也是断断续续发出的,
    很有可能由于你鼠标移动的快,让你>200的条件形同虚设,根本进不来,
    最好是在OnSetCursor中动态判断鼠标位置
      

  8.   

    原来如此,你说的有道理,那请问OnSetCursor的几个参数是怎么设置的呢?
    我看过但没懂
      

  9.   

    BOOL CCursorTestView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // TODO: Add your message handler code here and/or call default
    POINT point;
    GetCursorPos(&point); CRect rect;
    GetClientRect(rect); ScreenToClient(&point); if (point.y < rect.Height()/2)
    {
    if (point.x < rect.Width()/2)
    {
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_UPLEFT));
    }
    else
    {
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_UPRIGHT));
    }
    }
    else
    {
    if (point.x < rect.Width()/2)
    {
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_DOWNLEFT));
    }
    else
    {
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_DOWNRIGHT));
    }
    }

    return CView::OnSetCursor(pWnd, nHitTest, message);
    }void CCursorTestView::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    this->OnSetCursor(this, HTCLIENT, WM_SETCURSOR);
    CView::OnMouseMove(nFlags, point);
    }