请问哪位高手能指导一下,在单文档(支持文档/视图)中制作一个类似登录框一样的东西,就是先显示对话框,处理完后,再显示整个SDI.因为选择了支持/视图后,不知道如何设计了,以前都是在CXXXAPP的
InitInstance()函数里面,添加并显示对话框,但现在好像这样是不可以的,因为对话框和SDI会同时出现,一个比较傻的方法就是
在里面添加m_pMainWnd->ShowWindow(SW_HIDE);但,画面会闪一下,很不美观,不知道还有什么办法,请指教.BOOL CTryApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable, you should remove from the following
//  the specific initialization routines you do not need. // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings();  // Load standard INI file options (including MRU) // Register the application's document templates.  Document templates
//  serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTryDoc),
RUNTIME_CLASS(CMainFrame),       // main SDI frame window
RUNTIME_CLASS(CTryView));
AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
}
return TRUE;
}

解决方案 »

  1.   

    你在   m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    之前 if(dlg.Domodal()==IDOK) 即可
      

  2.   

    这样是不可以的,要注意,这是支持文档视图的,和普通的单文档有点区别,对话框和SDI会同时出现.不过这个问题我已经解决了.不过还是要谢谢你.解决方法如下:
    在APP头文件中,添加一个public变量bool flag;
    然后在VIEW头文件中添加一个CXXAPP* p,
    在CPP文件的构造函数中添加一条p=(CXXAPP*)AfxGetApp();然后改写虚函数OnInitialUpdate()在函数里面显示对话框,如
    if(dlg.DoModal()!=IDOK)
    {
    p->flag=false;
    }
    else p->flag=true;在APP的InitInstance()里面,
    在m_pMainWnd->ShowWindow(SW_SHOW);语句前
    判断flag就可以了.