模态对话框的建立模态对话框
1.选择File/New/MFC AppWizard[exe],Project name为Test,单击OK.
2.选择Single document,单击Finish.
3.选择左侧Workspace/ResourceView,在Dialog上单击右键,选择Insert Dialog,默认名字为IDD_DIALOG1.
4.双击右侧工作区中的对话框,弹出一对话框Adding a Class,默认选择Create a new class,单击OK.
5.在对话框New Class中,在Name中填入CDialogproty,Base class选择缺省名字CDialog,单击OK.在MFC ClassWizard 上选择OK.
6.选择左侧Workspace/ClassView,双击CTestView
#include Dialogproty.h
class CTestView : public CView
{
protected: // create from serialization only
7.选择左侧Workspace/ResourceView/Menu,双击IDR_MIANFRAME,在右侧工作区上方,帮助(H)后双击,弹出对话框Menu Item Properties,点击General/Pop-up,选为非选择状态,在ID内输入IDR_TEST,Caption中输入Test,关闭对话框Menu Item Properties,
8.在按钮Test上点击右键,选择ClassWizard...,在Messages中选择COMMAND,点击Add Function...,弹出对话框Add Member Function,点击OK,选择Edit Code.
9.在以下函数中添加代码
void CTestView::OnTest()
{
// TODO: Add your command handler code here
CDialogproty dlg;
dlg.DoModal();
}
10.编译,运行。点击菜单按钮Test,弹出对话框,点击OK!完成!