我DEBUG了一下,发现问题在SetDlgItemText()函数里
ASSERT(::IsWindow(m_hWnd)),这里跳出错

解决方案 »

  1.   

    先看看GetActiveView()得到的指针是否有效!
      

  2.   

    GetActiveView()->GetDlgItem(IDC_EDIT_TELENUM)->SetWindowText("12345678");
      

  3.   

    ASSERT(::IsWindow(m_hWnd))
    说明你的视图的指针或IDC_EDIT_TELENUM_1控件的句柄为0,请检查你调用该函数时,是否它们都有效。
      

  4.   

    你的问题在这:
       MDI中CMainFrame是不与任何View相关的,与View相关的只是CChildFrame因此
    你的GetActiveView()返回总是NULL。详细请看下面:This function returns NULL when called for an MDI main frame window (CMDIFrameWnd). In an MDI application, the MDI main frame window does not have a view associated with it. Instead, each individual child window (CMDIChildWnd) has one or more associated views. The active view in an MDI application can be obtained by first finding the active MDI child window and then finding the active view for that child window. The active MDI child window can be found by calling the function MDIGetActive or GetActiveFrame as demonstrated in the following:正确做法是:
    CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// Get the active MDI child window.
    CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();// or CMDIChildWnd *pChild = pFrame->MDIGetActive();// Get the active view attached to the active MDI child
    // window.
    CMyView *pView = (CMyView *) pChild->GetActiveView();
    加分哦!!!
      

  5.   

    我觉得是GetActiveView()调用后返回的是NULL,所以会出现那种错误。