-
April 17th, 2013, 11:43 AM
#1
How to set the parent dialog??
Hi all,
I’ve created a modeless dialog from my main dialog as follows:
Code:
m_pContainerDlg = new CDlgContainer(NULL, this);
m_pContainerDlg->Create(CDlgContainer::IDD, GetDesktopWindow());
m_pContainerDlg ->ShowWindow(SW_SHOW);
This container dialog creates a child dialog which I show inside the container
Code:
BOOL CDlgContainer::OnInitDialog()
{
// Create the child dialog and show it
m_pChildDlg = new CChildDlg(this);
m_pChildDlg->Create(IDD_DIRECTORY_DIALOG, this);
return FALSE;
}
From my child dialog I then create a modal dialog when a user clicks on a button
Code:
CChildDlg:: CChildDlg (CWnd* pParent /*=NULL*/) :
m_pParent((CDlgContainer*)pParent),
{
}
void CChildDlg::OnBnClickedBtn()
{
CMyDlg MyDlg;
INT_PTR iResult = MyDlg.DoModal(pParent);
}
My problem is that the CMyDlg is modal but to the main dialog and not to the container or the child dialog.
Can anyone please advise??
-
April 17th, 2013, 12:37 PM
#2
Re: How to set the parent dialog??
Originally Posted by Salvadoravi
From my child dialog I then create a modal dialog when a user clicks on a button
Code:
void CChildDlg::OnBnClickedBtn()
{
CMyDlg MyDlg;
INT_PTR iResult = MyDlg.DoModal(pParent);
}
My problem is that the CMyDlg is modal but to the main dialog and not to the container or the child dialog.
Does this code compile?
AFAIK CDialog::DoModal has no parameters at all:
http://msdn.microsoft.com/en-us/libr...v=vs.100).aspx
Victor Nijegorodov
-
April 17th, 2013, 01:08 PM
#3
Re: How to set the parent dialog??
"My problem is that the CMyDlg is modal but to the main dialog and not to the container or the child dialog."
I'm not even sure what that means. Modality isn't constrained or affected by a parent/child relationship.
-
April 18th, 2013, 02:09 AM
#4
Re: How to set the parent dialog??
Originally Posted by Salvadoravi
My problem is that the CMyDlg is modal but to the main dialog and not to the container or the child dialog.
Pointer to parent must be passed via constructor parameter, and your CMyDlg must have the corresponding constructor.
Code:
class CMyDlg: public CDialog
{
. . .
CMyDlg(CWnd* pParent = NULL): CDialog(IDD, pParent) {. . .}
};
CChildDlg:: CChildDlg (CWnd* pParent /*=NULL*/) :
m_pParent((CDlgContainer*)pParent),
{
}
void CChildDlg::OnBnClickedBtn()
{
CMyDlg MyDlg(this);
INT_PTR iResult = MyDlg.DoModal();
}
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|