在对话框上,移动图片控件上变成一只小手.

解决方案 »

  1.   

    在图片的MounseMove事件中加入
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_HANDLECURSOR));
    IDC_HANDLECURSOR这个为你的手形光标资源
      

  2.   

    case WM_MOUSEMOVE:
    ptMouse.x = LOWORD(lParam); //取lParam低字节为横坐标x
    ptMouse.y = HIWORD(lParam); //取lParam高字节为横坐标y
    fwKeys = wParam;
                      //将鼠标按钮和键盘组合赋给32位无符号整数fwKeys //下面代码对鼠标进行位置范围测试。如果鼠标落在位图上,那
                      //么把鼠标指针设置为自定义的
    //否则,采用普通的箭头鼠标。 if (PtInRect(&rect1, ptMouse) || PtInRect(&rect2, ptMouse)) //判断指定点是否在指定矩形内
    SetCursor(hCursorPen);
      

  3.   

    响应OnMouseMove()消息,判断鼠标位置,再调入相应的鼠标资源
      

  4.   

    如果要随时改变的话应该重载WM_SETCURSOR消息,如下
    BOOL CYourWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    if ( your candition )
    {
    ::SetCursor( m_hHintCur ); //m_hHintCur Your cusstom cursor
    return TRUE;
    }
    ::SetCursor( m_hNormalCur );
    return TRUE;
    return CParentWnd::OnSetCursor(pWnd, nHitTest, message);
    }
      

  5.   

    CTest6Dlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
    {
    CRect rect; 
    CPoint ptCursor; 
    CWnd *pStatic1=GetDlgItem(IDC_STATIC1);  pStatic1->GetWindowRect(rect); //得到static矩形的坐标

    GetCursorPos(&ptCursor); //得到mouse位置
    if(rect.PtInRect(ptCursor))
            { 
            CWinApp *pApp=AfxGetApp(); 
            HICON hIconBang=pApp->LoadCursor(IDC_MY_CURSOR);                  SetCursor(hIconBang); //设定此指针
    return TRUE; 

    else 
             //否则不设定
       return CDialog::OnSetCursor (pWnd, nHitTest, message);
    }
      

  6.   

    自己先在编辑器里建立好光标BOOL CHotdotDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // TODO: Add your message handler code here and/or call default
    switch(pWnd->GetDlgCtrlID())
    {
    case IDC_PICTURE1:
    SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR1));
    return TRUE;
    }
    return CDialog::OnSetCursor(pWnd, nHitTest, message);
    }