vc中基于对话框的程序中,怎么实现按一个按钮,之后打开一个新对话框并关闭原来的,把代码写在哪?
1个回答
2011-07-20
展开全部
最简便的方法就是:
定义一全局变量int flag;
然后在InitInstance()里(即在主对话框没显示之前的函数里)
flag=0;
while(flag>=0)
{
if(flag==0)
{
CIceDispImgDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
else if(flag ==1)
{
CIceNewDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
else
{
break;
}
}
在互相调用前,设置flag=0或=1,然后退出本身对话框即可
定义一全局变量int flag;
然后在InitInstance()里(即在主对话框没显示之前的函数里)
flag=0;
while(flag>=0)
{
if(flag==0)
{
CIceDispImgDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
else if(flag ==1)
{
CIceNewDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
else
{
break;
}
}
在互相调用前,设置flag=0或=1,然后退出本身对话框即可
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询