请问各位大虾:
我写了一个带视图/文档的MFC扩展DLL,
当主程序调用DLL中的函数dispReport()时,
执行到CWinApp* pApp = AfxGetApp();后
发现pApp为NULL
为什么?
怎么解决?
BOOL CReportTable::dispReport(){
AfxMessageBox("^_^");
BOOL bSuccess = FALSE; AfxMessageBox("1");
CWinApp* pApp = AfxGetApp();
AfxMessageBox("2");
ASSERT(pApp);
if(pApp)
{
AfxMessageBox("3");
CMultiDocTemplate* pDocTemplate; AfxMessageBox("4");
pDocTemplate = new CMultiDocTemplate(
IDR_REPORTTABLEDOCTYPE,
RUNTIME_CLASS(CReportDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CReportView));
AfxMessageBox("5");
ASSERT(pDocTemplate);
AfxMessageBox("6");
if(pDocTemplate){
AfxMessageBox("7");
pApp->AddDocTemplate(pDocTemplate);
bSuccess = TRUE;
}
AfxMessageBox("8");
}
AfxMessageBox("9");
return bSuccess;
}
我写了一个带视图/文档的MFC扩展DLL,
当主程序调用DLL中的函数dispReport()时,
执行到CWinApp* pApp = AfxGetApp();后
发现pApp为NULL
为什么?
怎么解决?
BOOL CReportTable::dispReport(){
AfxMessageBox("^_^");
BOOL bSuccess = FALSE; AfxMessageBox("1");
CWinApp* pApp = AfxGetApp();
AfxMessageBox("2");
ASSERT(pApp);
if(pApp)
{
AfxMessageBox("3");
CMultiDocTemplate* pDocTemplate; AfxMessageBox("4");
pDocTemplate = new CMultiDocTemplate(
IDR_REPORTTABLEDOCTYPE,
RUNTIME_CLASS(CReportDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CReportView));
AfxMessageBox("5");
ASSERT(pDocTemplate);
AfxMessageBox("6");
if(pDocTemplate){
AfxMessageBox("7");
pApp->AddDocTemplate(pDocTemplate);
bSuccess = TRUE;
}
AfxMessageBox("8");
}
AfxMessageBox("9");
return bSuccess;
}
AFX_MANAGE_STATE(AfxGetAppModuleState());
试试
AFX_MANAGE_STATE(AfxGetAppModuleState());
表明是动态库中的调用!
http://hao.kjz.cn/xml/040917142352.xml