I've coded an MFC CDialog
based application. In normal circumstances it starts up by displaying a CDialog
window from the InitInstance
handler as such:
CMyDialog dlg;
INT_PTR nResponse = dlg.DoModal();
But for the first time this app runs I need to display another dialog from within CMyDialog::OnInitDialog
before the main dialog is on the screen. So I do a similar thing:
CIntroDialog idlg(this);
idlg.DoModal();
But the issue with this approach is that my second CIntroDialog
is not displayed in the foreground. So I attempted to fix this by calling the following from within CIntroDialog::OnInitDialog
:
this->SetForegroundWindow();
this->BringWindowToTop();
but it didn't do anything.
I then tried calling ::AllowSetForegroundWindow(ASFW_ANY);
from InitInstance
for the app, and that didn't do anything either.
Any idea how to bring that second dialog to the foreground when the app starts?
PS. Due to the structure of this app, I need to call CIntroDialog::DoModal
from within CMyDialog::OnInitDialog
to prevent an extensive rewrite.
Have you consider making use of
InitInstance
for this in the app class?I have cut some of the default implementation out, but you see this bit:
There is nothing stopping you doing something like:
I admit I have not tested the above code, but I can't see why you can't execute the first dialogue and then the second dialogue.