Recently in learning VC + +, downloaded VS2013, according to the "Visual C + + development Practical treasure" of the first Hello routine wrote an example, the result of editing box garbled problem. Night has been tossing the type of conversion, and later summed up only to understand the difference between ANSI and Unicode. When the old tutorial just came out, these control interfaces are in ANSI format, and now they are all unified into Unicode.
void Chellodlg::onbnclickedok ()
{
CString Csplus; Defining string variables
CString Cssummand;
M_plusnumber.getwindowtext (Csplus); Gets the text in the edit box control
M_summand.getwindowtext (Cssummand);
int nplus = _wtoi(csplus);//atoi (Csplus.getbuffer (0)); Convert the text of an edit box to an integer
Csplus.releasebuffer ();
int nsummand = _wtoi(Cssummand);//atoi (Cssummand.getbuffer (0));
Cssummand.releasebuffer ();
int nret = Nplus + Nsummand; Perform addition operations
wchar_t chret[10] = {0};//char chret[128] = {0};
_itow_s (Nret, Chret, ten);//itoa (Nret, Chret, 10); Convert the result to a string
M_result.setwindowtext (Chret);
Todo:add your control notification handler code here
Cdialogex::onok ();
}
Visual C + + must be aware of the differences between ANSI and Unicode