Besides the already mentioned GetWindowText method, you can also bind it via DDX to the integer / unsigned integer / double / float value. Try the following:
void CYourAwesomeDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT_NUMBER, m_iNumber); }
whereas m_iNumber is a member of your CYourAwesomeDialog class.
You need to call
UpdateData(TRUE);
to write values ββfrom controls to variables. Call
UpdateData(FALSE);
to do it the other way around - from variables in controls.
EDIT (Bonus):
After reading my answer again, I noticed that UpdateData (...) needs the BOOL variable - fixed. So I got an idea for people who liked readability. Since I was always confused about what call I made in this direction, you could introduce an enumeration to make it more readable, for example (perhaps in stdafx.h or in some kind of central header):
enum UpdateDataDirection { FromVariablesToControls = FALSE, FromControlsToVariables = TRUE }
and you just need to write:
UpdateData(FromVariablesToControls);
or
UpdateData(FromControlsToVariables);
Cppchris
source share