It's really bad form to use this sort of naming in projects. None of those names have any significance in terms of what they are supposed to represent and, as you have discovered to your cost, it's easy to end up with basic errors such as the above.
[Agree 100% with this.]
To elaborate, the resource.h constants (ie. IDC_xxx) should have meaningful names, be numerically unique, the control/value variable names should be meaningful as well, and clearly related to the resource.h constants.
It's some years since I wrote any MFC code, but I don't quite understand what's going on here. Surely, if you map the same control to different variables then it is potentially going to end up with some items getting updated with the wrong values. Or do I need to go back and study DDX macros again?
No, the posted code looks fine, stylistic issues aside, so more information would be needed, in particular OnInitDialog and the button click message handler, but every place where UpdateData is called would need to be checked, as it's a quite common to overwrite the data you want before reading it, which is what I suspect happens here.
Personally, I think that using GetWindowText - which seems to work - makes more sense until one is more familiar with MFC and all its horribleness with magic macros. Use DDX_Control and get and set your data via the control instead.
Having a high ranking merely indicates that you post a lot of messages here, it does not indicate any level of skill or knowledge. Although, I do try to base my answers and comments on what I have learned, what I can test on my own system(s), or what I can find in the documentation. When I get it wrong I am more than happy to be corrected, that just means I will learn (and hopefully remember) something new.
Use the best guess
Last Visit: 31-Dec-99 18:00 Last Update: 1-Oct-23 18:39