Jan 10, 2013 at 8:32am UTC
Hi, I have a question.
In CWinApp, InitInstance() func has those things.
...
CMyDlg tdlg;
m_pMainWnd = &tdlg;
INT_PTR ret=tdlg.DoModal();
..
I wanted to show another dlg right after CMydlg destoryed, so I did like this.
CMyDlg tdlg;
m_pMainWnd = &tdlg;
INT_PTR ret=tdlg.DoModal();
if(ret == IDOK)
{}
else if(IDCANCEL)
{ return FALSE;}
CMyDlg2 tdlg2;
m_pMainWnd = &tdlg2;
tdlg2.doModal();
...
However, once CMyDlg returns IDOK, CMyDlg2.doModal()'s also termiated.
I need to know mfc process or something related to the reason i mentioned.
Anyone explain and help me.
Thanks. :)
Last edited on Jan 10, 2013 at 8:34am UTC
Jan 10, 2013 at 10:59am UTC
Have you not already asked this question 3 weeks ago??
Jan 10, 2013 at 11:17am UTC
I guess i did. but i needed to arrange my question cuz what I asked was not that clear. So, I re-post it. Plz understand me. :)
Jan 19, 2013 at 2:22pm UTC
It is all the way that MFC works:
The CWinApp class is derived from The CWinThread class.
The
m_pMainWnd member is in the CWinThread baseclass.
When the main window dies, then the CWinThread also effectively dies.
so when you first do this:
1 2 3
CMyDlg tdlg;
m_pMainWnd = &tdlg;
tdlg.DoModal();//show first dialogbox OK - afther dialogbox finishes, the thread dies with it.
But once that first Dialogbox finishes, it also finishes the associated thread
so when you try to use it again
1 2 3
CMyDlg2 tdlg2;
m_pMainWnd = &tdlg2;
tdlg2.doModal(); //nothing happens because the thread that runs the dialogbox is dead
Last edited on Jan 19, 2013 at 2:25pm UTC
Jan 19, 2013 at 4:04pm UTC
If you have a dialog box you should be able to call doModal until the cows come home.
while (dB.doModal() == IDOK);
Jan 19, 2013 at 4:46pm UTC
@ LowestOne - Not quite.
we are talking MFC and about changing the m_pMainWnd member of the CWinApp .
Jan 20, 2013 at 7:53am UTC
Thanks all.
And I got your saying, guestgulkan.
Thank you again.