A simple program using VC++
by Jordi Binefa
1- To add a public member object in
View class :
CString szText;
2- To load a value to szText object in
the constructor function in View class :
szText = ”By default”;
3- To add in function
C…View::OnDraw(CDC* pDC) :
pDC->TextOut(20,20,szText);
Now, you can execute the program.
4- To insert a new Dialog resource
(Ctrl+R).
5- To change IDD_DIALOG1 to
IDD_MY_DIALOG
6- To embed an edit box, changing its
name, IDC_EDIT1, to IDC_MY_EDIT
7- To invoke ClassWizard (Ctrl+W)
8- To create a new class : CMyDialog
9- In “Member Variables” to relate
IDC_MY_EDIT to a m_szMyEdit (CString)
10- To include MyDialog.h in …View.cpp
11- To invoke ClassWizard (Ctrl+W)
12- To select in “Message Maps” the
…View class through the combo box
13- Double click on WM_LBUTTONDBLCLK and
click Edit Code
14- To add under TODO:
CMyDialog md;
md.m_szMyEdit = szText;
if(md.DoModal() == IDOK){
szText
= md.m_szMyEdit;
Invalidate();
}
Now, you can execute the program.
15- To select IDR_MAINFRAME in
resources/Menu
16- To add a new item (i.e.:
“&Call”). To hang another item (i.e.: “My &Dialog”);
17- To invoke ClassWizard (Ctrl+W)
18- To select in “Message Maps” the
…View class through the combo box
19- Double click COMMAND (The wizard
suggests this function name : OnCallMydialog()) and click Edit Code
20- To repeat step 14
Now, you can execute the program