读书人

关于主窗口解决办法

发布时间: 2012-06-07 15:05:14 作者: rapoo

关于主窗口
求助:mfc对话框应用程序,在主窗口dlg1点击菜单项以DoModal方式弹出一新对话框(dlg2),如何销毁dlg1,使dlg2成为m_pMainWnd。谢谢帮忙!

[解决办法]
其实很简单:

C/C++ code
extern CGoDlg2App theApp;//void CGoDlg2Dlg::OnButton1() {    // TODO: Add your control notification handler code here    EndDialog(0);//Similar within app.cpp    CDialog2 dlg2;    theApp.m_pMainWnd = &dlg2;    int nResponse = dlg2.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    }} 

读书人网 >VC/MFC

热点推荐