MFC单文档中怎么在自定义的对话框类中使用文档类的数据

MFC单文档中如何在自定义的对话框类中使用文档类的数据
如题,自己在网上也搜了点相关内容,整理了比较靠谱的方法,如下
CMainFrame *pMain=(CMainFrame*)AfxGetApp()->m_pMainWnd; 
    CtestdocView *pView=(CtestdocView *)pMain->GetActiveView(); 
    CDocument *pDoc =/*AfxGetApp()->(CFrameWnd *)m_pMainWnd*/pMain->/*(CtestdocDoc*)*/GetActiveDocument(); 
CTestDlg dlg;
dlg.m_TestNum=pDoc->iTest;

其中CTestDlg是自定义的对话框类类,iTest是文档类C*Doc的成员变量,现报错如下:
error C2039: 'iTest' : is not a member of 'CDocument'

请教大神如何解决。。
------解决思路----------------------
iTest是你自己定义的变量吧,CDocument当然没有,如果你继承了CDocument,请把pDoc强制转换成你的派生类类型