許多未解決的問(wèn)題,先放一放,抽時(shí)間解決。
(1)增加Dialog資源
(2)為新的Dialog分配一個(gè)新類(lèi)名(對資源窗口“右鍵”->“添加類(lèi)”)
(3)在主對話(huà)框上加一個(gè)include "新類(lèi)名dialog.h"
大氣象
//顯示模態(tài)
newDialog newDlg;
newDlg.DoModal();
//得到對話(huà)框中控件的值,未實(shí)現,再研究。
CEdit *cEdit = (CEdit*) newDlg.GetDlgItem(IDC_EDIT1);
CString txtStr;
cEdit->GetWindowText(txtStr);
MessageBox(txtStr);
//非模態(tài)
CDialog *dlg = new CDialog;
dlg->Create(IDD_DIALOG1);
dlg->ShowWindow(SW_SHOWNA);
//非模態(tài),只顯示單個(gè)窗口,不能多個(gè)
if (dlg->IsWindowEnabled() == FALSE)//這里出錯了,不知何故。
{
dlg->Create(IDD_DIALOG1);
dlg->ShowWindow(SW_SHOWNA);
}
else
{
MessageBox(_T("已存在"));
dlg->ShowWindow(SW_SHOWNA);
}
//隱藏對話(huà)框
this->ShowWindow(SW_HIDE);
Sleep(3000);
this->ShowWindow(SW_SHOW);
//關(guān)閉/銷(xiāo)毀對話(huà)框
this->DestroyWindow();
this->EndDialog(0);
//最小化窗口
this->CloseWindow();