Using MFC to make a simple calculator, to deepen the understanding of MFC learning, this calculator is based on the dialog box, the following to briefly explain how to make your own calculator
1. First, click VS2012, launch the VS software, then build the application as shown, enter the project name below the diagram
2. create a dialog-based standard program, as shown in the rest of the settings using System settings, click Finish
3. For example, the software will generate the following dialog box, as well as the corresponding library, code, resource files, etc.
4. Edit the above dialog box, as shown in, the last edit looks like this, where 1,5,6 is the edit control, 2,7 is a static control, 3 is the buttion,4 is the Cancel button changed the name, the individual controls are sorted, and changed the name, The remainder uses the software default
5. 1, 5,7 the control to add a variable, right-click on the control and select the following
/span>
6. As variable add Wizard, 1 Select value,2 Select double (convenient to calculate decimal number) 3, is the variable name, we choose a, the same way, the 1,5,7 in the corresponding variable, respectively, the work a,b,sum
7. When you're done, double-click the Calculate button on the dialog box , the corresponding message map is generated, which is entered in the following code, see
/span>
8. /span>
Add the following code to this function, the parameter true in the Updatadate () function means getting the value from the control variable, false instead
Sum=a+b, which is the three variables we added to the control first, the calculator here is just for an addition.
9. after adding the above code, the compilation succeeds as follows
Ctrl+f5 Run as
Input values for addition calculation, you can do other related extensions, such as subtraction, multiplication, etc., are the same method
Using MFC to make a simple calculator in VS2012