我最近写了个小程序,是有关加载光标的,功能要求如下:在点击工具栏上的一按钮后,在客户区内的鼠标光标变为我所加载的光标,我加载的程序如下:
HANDLE m_hcurRubber;
m_hcurRubber = AfxGetApp()->LoadCursor(IDC_CURSOR_ORBIT);
BOOL CXiajing2006View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
// TODO: Add your message handler code here and/or call default
 CXiajing2006App *pApp=(CXiajing2006App *)AfxGetApp();
switch(pApp->Icon_kinds) {
             case 50: ::SetCursor(m_hcurRubber);
                   break; 
         default:
  break;         } 
      return   TRUE;  return CView::OnSetCursor(pWnd, nHitTest, message);
}
在加载光标我以完成,但我想多实现一个功能,就是在按键盘ESC键后光标变为原来的箭头光标,还请各位能指点一下.谢谢!!!!!

解决方案 »

  1.   

    键盘消息处理的时候重新LOAD要加载的光标就可
      

  2.   

    PreTranslateMessage(MSG *pMsg)
    {
     if(pMsg->message==WM_KEYDOWN)
      if(pMsg->wparam==VK_ESCAPE)
        if(pApp->Icon_kinds==50)
            pApp->Icon_kinds=51;
    .....}
    BOOL CXiajing2006View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
    {
    // TODO: Add your message handler code here and/or call default
     CXiajing2006App *pApp=(CXiajing2006App *)AfxGetApp();
    switch(pApp->Icon_kinds) {
                 case 50: ::SetCursor(m_hcurRubber);
                       break; 
                 case 51:
                       ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));         default:
      break;         } 
          return   TRUE;  return CView::OnSetCursor(pWnd, nHitTest, message);
    }