I am want to make a calculator on visual studio 2010 using MFC application. For this i used a dialog box to create calculator and add buttons and edit boxes. As we know that edit boxes are used as input. So i want to make the input as float input. So that’s what the below sentence is :
There is a sentence : First choose two edit boxes and placed them on dialog. Use the Class Wizard from the View menu to connect each to a float, value number1 or number2 .
Edit boxes are there. Now how to connect them to a float, value number 1 ? What’s the procedure?
Thanks
If I understand your question correctly, you want to bind the edit boxes to
floatmember variables of your dialog box. This is called dialog data exchange. In this answer, I will try to explain how to achieve this with code (it should be more helpful than teaching Class Wizard).Basically, you define two
floatmember variables in your dialog box, along with their accessors:Then, you override the DoDataExchange() method of the dialog box, and call DDX_Text() from there to bind the member variables to your controls:
From there, the MFC framework will automatically populate the edit boxes with the values of the member variables on dialog initialization, and update the member variables with the values of the edit boxes when the
OKbutton is clicked. This is a good thing because you only have to read and write to these member variables instead of manipulating the edit boxes directly.