Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio MFC:如何首先显示欢迎对话框?_Visual Studio_Visual C++_Mfc - Fatal编程技术网

Visual studio MFC:如何首先显示欢迎对话框?

Visual studio MFC:如何首先显示欢迎对话框?,visual-studio,visual-c++,mfc,Visual Studio,Visual C++,Mfc,启动程序时,我想先显示欢迎对话框,然后再显示主窗口。我目前的做法如下 BOOL CMyApp::InitInstance() { ... // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_HIDE); //m_pMainWnd->UpdateWindow(); // call DragAcceptFil

启动程序时,我想先显示欢迎对话框,然后再显示主窗口。我目前的做法如下

BOOL CMyApp::InitInstance()
{
    ...
    // The one and only window has been initialized, so show and update it
    m_pMainWnd->ShowWindow(SW_HIDE);
    //m_pMainWnd->UpdateWindow();
    // call DragAcceptFiles only if there's a suffix
    //  In an SDI app, this should occur after ProcessShellCommand

    CWelcomeDialog welcome_dialog;
    welcome_dialog.DoModal();

    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();

    return TRUE;
}
在InitInstance()的末尾,它最初使用(SW_SHOW)。起初,我试着对它进行评论,但它仍然显示出来。所以我改为(SW_HIDE)。它可以工作,但有令人不快的视觉伪影。有没有办法尽早停止显示主窗口

另一个问题是,当我隐藏主窗口并显示对话框时,对话框不在主窗口的中心位置


一般来说,如何实现欢迎对话框并在其他任何事情之前将其显示在中心位置?

您的想法是正确的:您的“启动屏幕”属于
CMyApp::InitInstance()
。请看这里的一个好例子:谢谢。这个例子看起来很好。当我有更多的时间时,我可能会更多地学习它。从简短的阅读中,我似乎只需要将其移到InitInstance()的最开头。为什么不在创建主窗口之前显示欢迎对话框呢?你自己也可以轻松完成对话框的居中。