void CDlgTopDlg::OnButton1()
{
// TODO: Add your control notification handler code here
// ShowWindow(SW_HIDE); // If I hide the main dialog, dlgsub10.DoModal() won't work
nResponse_sub10 = dlgsub10.DoModal();
while (1)
{
if (nResponse_sub10 == IDOK)
{
// show sub11
nResponse_sub11 = dlgsub11.DoModal();
while (1)
{
if (nResponse_sub11 == IDOK)
{
// show sub12
nResponse_sub12 = dlgsub12.DoModal();
if (nResponse_sub12 == IDOK)
{
nResponse_sub11 = dlgsub11.DoModal();
}
else if (nResponse_sub12 == IDCANCEL)
{
nResponse_sub11 = dlgsub11.DoModal();
}
}
else if (nResponse_sub11 == IDCANCEL)
{
nResponse_sub10 = dlgsub10.DoModal();
break;
}
}
}
else if (nResponse_sub10 == IDCANCEL)
{
//
// ShowWindow(SW_SHOW); //As I will show the dialog in full screen, so maybe keeping it show doesn't matter
break;
}
}
}
void CDlgTopDlg::OnButton2()
{
// TODO: Add your control notification handler code here
nResponse_sub20 = dlgsub20.DoModal();
if (nResponse_sub20 == IDOK)
{
// show sub
}
else if (nResponse_sub20 == IDCANCEL)
{
//
}
}
上面的代码是可以用的,不会出现多处嵌套导致堆栈溢出。
几个论坛求助:
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/1476ec8d-8f6e-41cd-87dc-9d53ab376672
http://topic.csdn.net/u/20121002/00/817ec5c4-6b3c-47db-8f13-120f39d6f909.html?seed=1422695499&r=79809168#r_79809168

这篇博客探讨了在VC环境下,如何有效地在多个对话框界面之间进行切换,避免堆栈溢出的问题。作者提供了相关论坛求助链接,讨论了在C++中处理对话框界面切换的解决方案。
3926

被折叠的 条评论
为什么被折叠?



