大家帮我看下,左右两个视 ,CT1View,CT2View要想点左边的视里的按钮,右边视文本框能显示文字,我用:
在MainFrm.h里定义了CT2View * m_pT2View;
在CT1View OnButton1() 命令按钮的事件中写下
((CMainFrame *)AfxGetMainWnd())->m_pT2View.m_edit="hello";
编译能通过,但我运行时,点击命令按钮,就提示出错,请问该怎么改?
  
 

解决方案 »

  1.   

    GetDocument()->UpdateAllViews(this,eventCode,&eventData);
      

  2.   

    ((CMainFrame *)AfxGetMainWnd())->m_pT2View.m_edit="hello";
    编译可行,为何运行时执行该语句会错!
      

  3.   

    我倒是觉得要用Docment指针来获取
      

  4.   

    首先在CDocument里面加入一个CString m_strView2;的成员然后在CT2View的UpdateView里加入
    m_edit = GetDocument()->m_strView2;接着在CT1View里的按钮事件中加入GetDocument()->UpdateAllView( this );
      

  5.   

    为何我的CT1DOCument没有updateAllView()方法?
      

  6.   

    CDocument::UpdateAllViews  Call this function after the document has been modified. void UpdateAllViews(
       CView* pSender,
       LPARAM lHint = 0L,
       CObject* pHint = NULL 
    );
    UpdateAllViews是文档类CDoumnent的函数,不是CView类的函数