VC++ CDialog用法的一些总结(转载)

来源:互联网 发布:java 线程池初始化 编辑:程序博客网 时间:2024/05/15 23:49
以下是我学习VC++ CDialog用法的一些总结:
(1)增加Dialog资源
(2)为新的Dialog分配一个新类名(对资源窗口"右键"->"添加类")
(3)在主对话框上加一个include "新类名dialog.h"
大气象//显示模态
newDialog newDlg;
newDlg.DoModal();

//得到对话框中控件的值,未实现,再研究。
CEdit *cEdit = (CEdit*) newDlg.GetDlgItem(IDC_EDIT1);
CString txtStr;
cEdit->GetWindowText(txtStr);
MessageBox(txtStr);

//非模态
CDialog *dlg = new CDialog;
dlg->Create(IDD_DIALOG1);
dlg->ShowWindow(SW_SHOWNA);

//非模态,只显示单个窗口,不能多个
if (dlg->IsWindowEnabled() == FALSE)//这里出错了,不知何故。
{
dlg->Create(IDD_DIALOG1);
dlg->ShowWindow(SW_SHOWNA);
}
else
{
MessageBox(_T("已存在"));
dlg->ShowWindow(SW_SHOWNA);
}

//隐藏对话框
this->ShowWindow(SW_HIDE);
Sleep(3000);
this->ShowWindow(SW_SHOW);

//关闭/销毁对话框
this->DestroyWindow();
this->EndDialog(0);

//最小化窗口
this->CloseWindow();

引:http://www.blue1000.com/bkhtml/c150/2010-11/69612.htm