Hide an MFC dialog window

后端 未结 6 2080
轮回少年
轮回少年 2020-12-19 17:46

I have written an MFC dialog based application which is launched by some another application. For now, I have not added any code. It is just the default files that I got. Th

6条回答
  •  甜味超标
    2020-12-19 18:09

    As soon as you call DoModal your dialog is doomed to be shown. There is only one workaround that successfully avoids focus/flicker problems. See my answer here: Hiding an MFC dialog box

    Hence, your code should look like this:

    BOOL CMyApp::InitInstance() 
    { 
        CMyAppDlg dlg;
        dlg.SetVisible(FALSE); // Sets m_visible flag to FALSE.
    
        m_pMainWnd = &dlg;         
    
        INT_PTR nResponse = dlg.DoModal(); 
    
        if (nResponse == IDOK) 
        { 
        } 
        else if (nResponse == IDCANCEL) 
        {  
        } 
    
        return FALSE; 
    } 
    

提交回复
热议问题