模态与非模态对话框 两个对话框之间值的传递
2013-08-11 23:12
246 查看
①、模态对话框的创建:CDialog::DoModal
不用释放资源
②、非模态对话框的创建:CDialog::Create
>: MyDialog dlg; 静态存储区域:全局变量 与 DestroyWindow(); 函数配合使用释放资源
>: 堆中申请内存: DestroyWindow()和PostNcDestroy()函数配合使用
③、两个对话框之间值的传递
不用释放资源
②、非模态对话框的创建:CDialog::Create
>: MyDialog dlg; 静态存储区域:全局变量 与 DestroyWindow(); 函数配合使用释放资源
MyDialog dlg; void CLessonOneDlg::OnBnClickedButton1() { dlg.Create(ID_MY_DIALOG,this); dlg.ShowWindow(SW_SHOW); } void MyDialog::OnOK() { // TODO: Add your specialized code here and/or call the base class MessageBox(_T("OnOK")); DestroyWindow(); //CDialog::OnOK(); }
>: 堆中申请内存: DestroyWindow()和PostNcDestroy()函数配合使用
MyDialog *dlg = new MyDialog(); dlg->Create(ID_MY_DIALOG,this); dlg->ShowWindow(SW_SHOW); ------------------------------------------------------------- void MyDialog::OnCancel() { DestroyWindow(); //CDialog::OnCancel(); } void MyDialog::PostNcDestroy() { delete this; //CDialog::PostNcDestroy(); }
③、两个对话框之间值的传递
①、全局变量法: CString str; extern CString str; ②、主对话框法:AfxGetMainWnd(); CLessonOneDlg *dlg1 = (CLessonOneDlg*)AfxGetMainWnd(); ③、父窗口法:GetParent();CLessonOneDlg *dlg1 = (CLessonOneDlg*)GetParent(); ④、成员变量、成员函数法; CLessonOneDlg *oneDlg; |
相关文章推荐
- MFC中两个对话框之间数据传递
- WM_COPYDATA两个对话框之间传递数据的乱码问题
- MFC中两个对话框之间数据传递
- VC 两个对话框之间的参数传递(1)
- MFC中两个对话框之间数据传递
- MFC中两个对话框之间数据传递
- VC 两个对话框之间的参数传递(1)
- 模态对话框/非模态对话框/系统对话框CColorDialog 置顶问题/显示最前面/TopMost
- Qt - 模态对话框与非模态对话框
- 父窗体与子窗体之间的调用-使用模态窗体之间传递多个值
- Qt 模态对话框与非模态对话框及生命周期
- Android上在两个Activity之间传递Bitmap对象
- 两个Fragment之间的跳转,和数据的传递
- 两个Fragment之间参数的传递
- MFC模态对话框和非模态对话框
- QT创建模态对话框阻塞整个应用程序和非模态对话框唯一性约束的简单示例
- Android中两个Activity之间数据传递及返回
- 3. 调用另一个Activity,并两个Activity之间相互传递数据
- html5的bootstrap模态框与js之间的值传递
- 非模态对话框与模态对话框对比