我在一个cview类中内嵌一个CTreeCtrl对象,请问我如何在框架中得到CTreeCtrl的消息,如:单击项目时产生相应动作

解决方案 »

  1.   

    根据doc/view结构的消息分流过程,你的框架类是不能收到view类中的command消息的,除非你在view类中自定义消息转发给你的框架类。
      

  2.   


       BOOL CMyXxx::PreTranslateMessage(MSG* pMsg)
       {
          // If edit control is visible in tree view control, when you send a
          // WM_KEYDOWN message to the edit control it will dismiss the edit
          // control. When the ENTER key was sent to the edit control, the
          // parent window of the tree view control is responsible for updating
          // the item's label in TVN_ENDLABELEDIT notification code.
          if (pMsg->message == WM_KEYDOWN &&
             pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
          {
             CEdit* edit = m_TreeCtrl.GetEditControl();
             if (edit)
             {
                edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
                return TRUE;
             }
          }
          // CXxxx can be a CFormView, Cdialog, or CPropertyPage class.
          return CXxxx::PreTranslateMessage(pMsg);
       }
      

  3.   

    kekepengpeng2(磕磕碰碰2) 这里也看到你。你说的没错,并且,补充一下CTreeCtrl要在得到焦点的情况下才对操作产生响应。