Opening other modal dialog box in OnInitDialog
Posted on 2008-10-14
I'm working on a single document based application using VC++ 2008 / Windows XP. I have created a simple CDialog-derived class "CMyDialog" and overridden its OnInitDialog to initialize the controls of my dialog box.
Now, I open CMyDialog using DoModal:
The dialog opens as expected. While CMyDialog is opened, the user cannot interact with other windows until the CMyDialog is closed. So far so good.
Under certain conditions, I may need to open another modal dialog box from CMyDialog::OnInitDialog:
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
This is where I get confused. Once CMyDialog2 is closed, CMyDialog opens as expected, but it is not "modal" anymore. In other words CMyDialog is opened, but I can also interact with the other windows under it. I would like to understand why this happens and is there a way to prevent it assuming I do want to open other modal dialog box from OnInitDialog?