如何在自建的派生类对话框中,得到视图-文档结构中的文档指针? 你在定义CMydialog dia(this); 时将视图的指针带入dialog 中,然后在dialog 中pParent->GetDocument();就行了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CDocument* pActiveDocument=((CMDIFrameWnd*)AfxGetMainWnd()) ->GetActiveFrame()->GetActiveDocument() CDocument* pActiveDocument=((CMDIFrameWnd*)AfxGetMainWnd()) ->GetActiveFrame()->GetActiveDocument() 何必这么累呢,在对话框类里加入一个文档指针,在定义对话框对象是把文档指针赋给它CMyDlg dlg;dlg.m_pMyDoc=pDoc;dlg.DoModel(); CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;CDocument* pDoc=pFrame->GetActiveDocument();如果要得到你自己的Doc,则CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;CMyDoc* pDoc=(CMyDoc*)pFrame->GetActiveDocument();且在对话框上加上#include "MyDoc.h" 在view里:CXXXDialog* pXXXDlg=NULL;if(!pDateDlg) { pXXXDlg=new CXXXDialog(this); ASSERT(pXXXDlg);}在dialog的构造函数里:CXXXDialog::CXXXDialog(CWnd* pParent /*=NULL*/) : CDialog(CXXXDialog::IDD, pParent){ …… …… m_pView=(CYourView*)pParent; //m_pView的定义:CYourView* m_pView; }doc的指针: CYourDoc* pDoc=m_pView->GetDocument(); return pDoc; 如何用VC提取WEB中的信息? 关于界面库的设计 双星了!散分! Initsock.h的问题 急!!!socket分别编写一客户端程序和服务器程序 求助关于一个窗口会自动乱跑是什么原因呢? 程序成功编译运行退出时出错,高手指教 求助 EDITVIEW问题 哪位兄弟知道什么地方有《Windows系统编程》的电子书免费下载?谢谢了! :*.idl文件怎么用? 为何我的程序在win xp下运行出错? SDK编程关于直接显示对话框的问题
((CMDIFrameWnd*)AfxGetMainWnd())
->GetActiveFrame()->GetActiveDocument()
->GetActiveFrame()->GetActiveDocument()
在对话框类里加入一个文档指针,在定义对话框对象是把文档指针赋给它
CMyDlg dlg;
dlg.m_pMyDoc=pDoc;
dlg.DoModel();
CDocument* pDoc=pFrame->GetActiveDocument();
如果要得到你自己的Doc,则
CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CMyDoc* pDoc=(CMyDoc*)pFrame->GetActiveDocument();
且在对话框上加上#include "MyDoc.h"
CXXXDialog* pXXXDlg=NULL;
if(!pDateDlg)
{
pXXXDlg=new CXXXDialog(this);
ASSERT(pXXXDlg);
}
在dialog的构造函数里:
CXXXDialog::CXXXDialog(CWnd* pParent /*=NULL*/)
: CDialog(CXXXDialog::IDD, pParent)
{
……
……
m_pView=(CYourView*)pParent;
//m_pView的定义:CYourView* m_pView;
}
doc的指针:
CYourDoc* pDoc=m_pView->GetDocument();
return pDoc;