I'm trying to nest dialog boxes and it works effortlessly with a single level of nesting but the second level "breaks" - the inner-most dialog doesn't get events.
[IDD_NESTEDDLG_DIALOG]
|
+--- [IDD_CHILD1]
|
+--- [IDD_CHILD2]
Both children dialog boxes are set to have style as "Child". For this test I'm just using a straight-up MFC wizard: created a dialog-based app, added two children dialog boxes (both derived from CDialogEx
), added member-variables to hold instances of those children dialog boxes. No customization beyond creating children dialog boxes and displaying them in OnInitDialog()
:
BOOL CnestedDlgDlg::OnInitDialog()
{
// ... MFC-generated bootstrap
m_child1.Create(IDD_CHILD1);
m_child1.ShowWindow(SW_SHOW);
return TRUE;
}
and
BOOL CChild1::OnInitDialog()
{
// ... MFC-generated bootstrap
m_child2.Create(IDD_CHILD2);
m_child2.ShowWindow(SW_SHOW);
return TRUE;
}
When I run this code both nested dialog boxes are properly shown yet only the top-level and first-level dialog boxes get events. Clicking on IDD_CHILD1
's "OK" or "Cancel" button promptly closes that intermediate dialog and only then the inner-most child dialog starts getting events.
I feel like there's something very trivial I'm missing here but hours of playing with various settings ("Control", "Control Parent", "No Idle Message", "No Parent Notify") and searching the Web yielded no progress so far.
How do I properly nest dialog boxes so that the second-level child's controls get events while the top-level and first-level dialog controls are also active?
UPDATE
Once I made both children boxes have "normal" borders I was able to move them around inside the top-level dialog box and noticed that the second-level child feels more like a sibling to the first-level dialog box than its child. The issue is probably there, but I still don't know how to properly deal with that. And there's also a problem with a re-draw as it seems both children boxes don't get to be repainted unless the app is minimized/restored or moved out the screen.
Create()
andShowWindow()
– YePhIcK