简体   繁体   English

如何在MFC中同时创建两个活动对话框?

[英]How to make two active dialogs in the same time in MFC?

I'm trying to run two windows in MFC in the same time - when i run my app. 我试图同时在MFC中运行两个窗口-运行我的应用程序时。 In BOOL CrTestTaskApp::InitInstance() - init function of my app i wrote this: 在BOOL CrTestTaskApp :: InitInstance()-我的应用程序的初始化函数中,我这样写:

CrStartDlg sDlg;
sDlg.DoModal();
CrMainDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

if (nResponse == IDOK)
{

}
else if (nResponse == IDCANCEL)
{

}

But second dialog apears only after i closed first. 但是第二个对话只有在我先关闭后才会出现。 And also, if i make Modal() second dialog on BtnClick() first dialog - i cant switch between them.. Active only one... 而且,如果我在BtnClick()第一个对话框上创建Modal()第二个对话框-我无法在它们之间切换。.仅激活一个...

Help me pls. 请帮助我。

You need modeless dialogs, as opposed to modal created by DoModal method. DoModal方法创建的模式不同,您需要无模式的对话框。

Modeless dialogs are created with CDialog::Create and act as regular windows, responding to messages dispatched via shared message queue/pump. 使用CDialog::Create无模式对话框并充当常规窗口,以响应通过共享消息队列/泵发送的消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM