GetDlgItemText
copies the text form the edit control into buffer and returns the number of characters read from dialog control, not the text interpreted as a number. The way to go is to first convert the string in buffer
to an integer and then supply this to output.Format
. For example, you can do this with the function atoi
. Your modified code would look like this:
TCHAR buffer[500];
GetDlgItemText(TOCON, buffer, 50);
int input = atoi(buffer);
CString output;
output.Format(L"%x", input);
m_oput.SetWindowText(output);