@@ -37,11 +37,16 @@ The procedures use the following names and values:
37
37
38
38
1 . Add the following include statement to CDisplayDialogDoc.cpp (or CDisplayDialogApp.cpp) after the existing include statements:
39
39
40
- [ !code-cpp[ NVC_MFCControlLadenDialog#42] ( ../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_1.cpp )]
40
+ ``` cpp
41
+ #include " TestDialog.h"
42
+ ```
41
43
42
44
1 . Add the following code to ` OnViewTest ` to implement the function:
43
45
44
- [ !code-cpp[ NVC_MFCControlLadenDialog#43] ( ../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_2.cpp )]
46
+ ``` cpp
47
+ CTestDialog testdlg;
48
+ testdlg.DoModal();
49
+ ```
45
50
46
51
### To display a modeless dialog box
47
52
@@ -51,29 +56,46 @@ The procedures use the following names and values:
51
56
52
57
- Declare the dialog box class preceding the first class declaration:
53
58
54
- [!code-cpp[NVC_MFCControlLadenDialog#44](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_3.h)]
59
+ ``` cpp
60
+ class CTestDialog ;
61
+ ```
55
62
56
63
- Declare a pointer to the dialog box after the Attributes public section:
57
64
58
- [!code-cpp[NVC_MFCControlLadenDialog#45](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_4.h)]
65
+ ``` cpp
66
+ CTestDialog* m_pTestDlg;
67
+ ```
59
68
60
69
1 . Edit DisplayDialogView.cpp:
61
70
62
71
- Add the following include statement after the existing include statements:
63
72
64
- [!code-cpp[NVC_MFCControlLadenDialog#42](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_1.cpp)]
73
+ ``` cpp
74
+ #include " TestDialog.h"
75
+ ```
65
76
66
77
- Add the following code to the constructor:
67
78
68
- [!code-cpp[NVC_MFCControlLadenDialog#46](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_5.cpp)]
79
+ ``` cpp
80
+ m_pTestDlg = NULL ;
81
+ ```
69
82
70
83
- Add the following code to the destructor:
71
84
72
- [!code-cpp[NVC_MFCControlLadenDialog#47](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_6.cpp)]
85
+ ``` cpp
86
+ delete m_pTestDlg;
87
+ ```
73
88
74
89
- Add the following code to ` OnViewTest ` to implement the function:
75
90
76
- [!code-cpp[NVC_MFCControlLadenDialog#48](../mfc/codesnippet/cpp/example-displaying-a-dialog-box-via-a-menu-command_7.cpp)]
91
+ ``` cpp
92
+ if (NULL == m_pTestDlg)
93
+ {
94
+ m_pTestDlg = new CTestDialog(this);
95
+ m_pTestDlg->Create(CTestDialog::IDD, this);
96
+ }
97
+ m_pTestDlg->ShowWindow(SW_SHOW);
98
+ ```
77
99
78
100
## See also
79
101
0 commit comments