先简单的说一下,我现在的一个程序,有一个用户登陆的对话框,还有一个splash screen,是这么写的
BOOL CRiskApp::InitInstance()
{        ...
m_pMainWnd->ShowWindow(SW_HIDE);
m_pMainWnd->UpdateWindow();
return TRUE;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{        ...
CSplashWnd::ShowSplashScreen(this);
return 0;
}
void CSplashWnd::HideSplashScreen()
{
DestroyWindow();
CUserLogDlg LogDlg;
if(IDOK!=LogDlg.DoModal ())
{
::PostQuitMessage(0);
}
AfxGetMainWnd()->ShowWindow(SW_SHOW);
AfxGetMainWnd()->UpdateWindow();
}这样可以正常显示,但是我想把CUserLogDlg 的一个变量传给Doc文件CRiskDoc,用语句
CRiskDoc *pDoc=(CRiskDoc *)GetDocument();
pDoc->m_nLevel =LogDlg.m_nLevel ;
但是不行,加上头文件后,错误是“CRiskDoc *pDoc=(CRiskDoc *)GetDocument();”
我的目的就是既有Splash screen,还能显示登陆对话框,并把对话框的值传给CRiskDoc
很急,在线请大侠指点。

解决方案 »

  1.   

    对话框的变量m_nLevel和对话框控件设置数据交换了吗?
      

  2.   

    在提示错误的地方include CRiskView.h和CRiskDoc.h.
      

  3.   

    我觉得这样设计并不好,为什么不是把CUserLogDlg 的一个变量传给App呢?document在从app中取得?
      

  4.   

    支持楼上的,使用App传递很方便。
      

  5.   

    在CSplashWnd的cpp中加入#include CRiskDoc.h #include "mainfrm.h"CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;
    CRiskDoc *pDoc = (CRiskDoc *)pFrame->GetActiveDocument();