I just installed Visual Studio 2017 community edition. I created a MFC project using the app wizard taking all the defaults. Then I added two edit boxes on the about dialog. Then I mapped two variables of type double to these two edit boxes. Then I added a handler for OK button. Here is relevant code:
class CAboutDlg : public CDialogEx
{
double m_f;
afx_msg void OnBnClickedOk();
double m_f2;
};
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_f);
DDX_Text(pDX, IDC_EDIT2, m_f2);
}
void CAboutDlg::OnBnClickedOk()
{
if (!UpdateData(TRUE))
{
return;
}
CString s;
s.Format(_T("m_f = %g"), m_f);
AfxMessageBox(s);
s.Format(_T("m_f2 = %g"), m_f2);
AfxMessageBox(s);
CDialogEx::OnOK();
}
What I noticed is that in Release mode, if I entered 0.56 in the first edit box and 0 in the second edit box and click OK button. The m_f and m_f2 values are displayed as 0.56 and 56 (instead of 0). Anyone else notice this bug? I cannot believe existence of such a bug.
I also played around with the project general settings such as Windows SDK version, Platform Toolset, use of MFC (static or shared library) and character set (Unicode or nonUnicode). The only setting that I get the values displayed correctly is to use Windows SDK version = 10.0.15063.0, Platform toolset=Visual Studio 2017 v141, use MFC static library.
GetWindowText
give? – Ajay