为什么在用MFC生成的基于对话框程序中,
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
COtherDlg odlg;
odlg.DoModal();
}
在TODO处加入对OK键的响应代码,编译可以通过,但却不显示odlg对话框呢?
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
COtherDlg odlg;
odlg.DoModal();
}
在TODO处加入对OK键的响应代码,编译可以通过,但却不显示odlg对话框呢?
MFC規定, 你這種做法是不行的,我也像你這樣試過,未果
例如說你點的是取消...你Debug看看..
这样不行吗?那要把代码放到什么地方?OnOK()?Debug过了,正常,这儿好像显示了一下对话框,但马上消失了!
系统自动按了OK?
为什么会这样,那这段话是什么意思:
// TODO: Place code here to handle when the dialog is
// dismissed with OK
不是对OK的处理吗,这儿为什么不能话代码?:(
其實那還是會打開的.但可能是缺少了窗口指針.所以使得不再有效(個人想法)
// m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
CotherBox odlg;
odlg.DoModal();
}
这样就可以了,注释掉向导生成的m_pMainWnd = &dlg;但这样会有什么后果吗?请大家讨论啊!
可以生成多个对话框,如果把其中一个赋给m_pMainWnd的话
只要这个对话框消失,则其它的都不显示了!
是这样吗?