做一个对话框,然后再创建一个新的View(比如说CListView,不能用CListCtrl)。让他显示到对话框上。怎么做

解决方案 »

  1.   

    告诉我你的mail,我发给你一个例子。我的mail
    [email protected]
      

  2.   

    BOOL CVwindlgDlg::OnInitDialog()
    {     ...  CCreateContext pContext;
      /**
      * Note:CDialig derived pointer is converted to
      * CWnd pointer (a common base class for CDialog and CFrameWnd).
      * Thus casting it back to CFrameWnd is also easy.
      */
      CWnd* pFrameWnd = this;
      
      pContext.m_pCurrentDoc = new CMyDocument;
      pContext.m_pNewViewClass = RUNTIME_CLASS(CMyVw);
      CMyVw *pView =
         (CMyVw *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
      ASSERT(pView);
      pView->ShowWindow(SW_NORMAL);
      /**
      * After a view is created, resize that to 
      * have the same size as the dialog.
      */
      CRect rectWindow;
      GetWindowRect(rectWindow);
      /**
      * Leave a little space for border and title...
      */
      rectWindow.right += 15;
      rectWindow.top   -= 10;
      pView->MoveWindow(rectWindow);
      CString str(AfxGetApp()->m_lpCmdLine);
      /**
      * Note: "CMyVw" is a CHTMLView derived class to add some 
      *       spice to the view, I have provided a HTML page 
      *       to which it navigates when the dialog is up.
      */
      char strPath[255];
      ::GetCurrentDirectory(255,(LPSTR)(LPCSTR)strPath);
      strcat(strPath,"\\defaultpage.html");
      pView->Navigate(strPath);         ....  return TRUE;  // return TRUE  unless you set the 
                    // focus to a control
    }