Stupid problem
-
Well, actually I don't even know what the problem is. :sigh: It's like this. I have a dialog box which reads some values from a file to initialize itself. I do this in
OnInitDialog()
. Fine. But when the dialog finally shows up, one of the checkboxes is not checked. I mean, it should have been, according to the settings it reads from the file. I checked the value just after reading the settings, to make sure that it's indeed getting read properly. It is. AfterReadSettings()
(my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this functionUpdateData(FALSE)
is called to put these values in the controls on the dialog box to which they correspond. Things are just as they should be, except for one particular checkbox. And afterUpdateData()
the value of the variable is also somehow set toFALSE
on its own. WTF is going on? When I try to change the settings or something, and write the new values back into the file, they get written properly, including for this checkbox. So the variable is properly connected to the control. But what happens duringUpdateData(FALSE)
? Or am I looking at the problem in an entirely wrong way? I'm not a newbie or anything. But this thing has me baffled. I must be missing something very very obvious and stupid. I very rarely ask for help, but in order to save the walls around me from developing cracks from banging my head on them, I must do so now. Suggestions, please? I need to get this done today. Doh. Stupid me.
Regards,Rohit Sinha
Do not wait for leaders; do it alone, person to person.
- Mother Teresa -
Well, actually I don't even know what the problem is. :sigh: It's like this. I have a dialog box which reads some values from a file to initialize itself. I do this in
OnInitDialog()
. Fine. But when the dialog finally shows up, one of the checkboxes is not checked. I mean, it should have been, according to the settings it reads from the file. I checked the value just after reading the settings, to make sure that it's indeed getting read properly. It is. AfterReadSettings()
(my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this functionUpdateData(FALSE)
is called to put these values in the controls on the dialog box to which they correspond. Things are just as they should be, except for one particular checkbox. And afterUpdateData()
the value of the variable is also somehow set toFALSE
on its own. WTF is going on? When I try to change the settings or something, and write the new values back into the file, they get written properly, including for this checkbox. So the variable is properly connected to the control. But what happens duringUpdateData(FALSE)
? Or am I looking at the problem in an entirely wrong way? I'm not a newbie or anything. But this thing has me baffled. I must be missing something very very obvious and stupid. I very rarely ask for help, but in order to save the walls around me from developing cracks from banging my head on them, I must do so now. Suggestions, please? I need to get this done today. Doh. Stupid me.
Regards,Rohit Sinha
Do not wait for leaders; do it alone, person to person.
- Mother TeresaI know this kind of hassle with the stupid UpdateData() part. There is so much happening behind your back, you never know what went wrong! I tend to drop DDX/DDV entierly, have the class wizard make me some control-variables and do the data transfer myself. I know when to do what, like validating on each keypress, or on the TAB-key or..or..or. All DDX/DDV can is validate on OK-Button. Having said that, All I can think of at the moment is the following: The variable you are setting IS connected with the right control? Look it up in the DDX_TEXT() macros at the top of the cpp. You can set a breakpoint on the macro and step through the DDX-function. Hope that helped
Who is 'General Failure'? And why is he reading my harddisk?!?
-
Well, actually I don't even know what the problem is. :sigh: It's like this. I have a dialog box which reads some values from a file to initialize itself. I do this in
OnInitDialog()
. Fine. But when the dialog finally shows up, one of the checkboxes is not checked. I mean, it should have been, according to the settings it reads from the file. I checked the value just after reading the settings, to make sure that it's indeed getting read properly. It is. AfterReadSettings()
(my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this functionUpdateData(FALSE)
is called to put these values in the controls on the dialog box to which they correspond. Things are just as they should be, except for one particular checkbox. And afterUpdateData()
the value of the variable is also somehow set toFALSE
on its own. WTF is going on? When I try to change the settings or something, and write the new values back into the file, they get written properly, including for this checkbox. So the variable is properly connected to the control. But what happens duringUpdateData(FALSE)
? Or am I looking at the problem in an entirely wrong way? I'm not a newbie or anything. But this thing has me baffled. I must be missing something very very obvious and stupid. I very rarely ask for help, but in order to save the walls around me from developing cracks from banging my head on them, I must do so now. Suggestions, please? I need to get this done today. Doh. Stupid me.
Regards,Rohit Sinha
Do not wait for leaders; do it alone, person to person.
- Mother TeresaSouns like a silly, I assume you are using the MFC? try deleteing and the name of the member variable of the check box and then compile, are there any errors. Now add a new member variable name, and set it TRUE or FALSE manually. If this fails then you are probably overwritng some memory location. Or comment out everything possible from the class, does it still fail? Good luck!
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
-
Well, actually I don't even know what the problem is. :sigh: It's like this. I have a dialog box which reads some values from a file to initialize itself. I do this in
OnInitDialog()
. Fine. But when the dialog finally shows up, one of the checkboxes is not checked. I mean, it should have been, according to the settings it reads from the file. I checked the value just after reading the settings, to make sure that it's indeed getting read properly. It is. AfterReadSettings()
(my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this functionUpdateData(FALSE)
is called to put these values in the controls on the dialog box to which they correspond. Things are just as they should be, except for one particular checkbox. And afterUpdateData()
the value of the variable is also somehow set toFALSE
on its own. WTF is going on? When I try to change the settings or something, and write the new values back into the file, they get written properly, including for this checkbox. So the variable is properly connected to the control. But what happens duringUpdateData(FALSE)
? Or am I looking at the problem in an entirely wrong way? I'm not a newbie or anything. But this thing has me baffled. I must be missing something very very obvious and stupid. I very rarely ask for help, but in order to save the walls around me from developing cracks from banging my head on them, I must do so now. Suggestions, please? I need to get this done today. Doh. Stupid me.
Regards,Rohit Sinha
Do not wait for leaders; do it alone, person to person.
- Mother TeresaYou're likely to solve the problem by using member control variables instead of
UpdateData()
. See jhwurmbach's comment. -
I know this kind of hassle with the stupid UpdateData() part. There is so much happening behind your back, you never know what went wrong! I tend to drop DDX/DDV entierly, have the class wizard make me some control-variables and do the data transfer myself. I know when to do what, like validating on each keypress, or on the TAB-key or..or..or. All DDX/DDV can is validate on OK-Button. Having said that, All I can think of at the moment is the following: The variable you are setting IS connected with the right control? Look it up in the DDX_TEXT() macros at the top of the cpp. You can set a breakpoint on the macro and step through the DDX-function. Hope that helped
Who is 'General Failure'? And why is he reading my harddisk?!?
Well, sometimes we are stupid and sometimes we don't follow the docs. That's what happened with me. :) I was reading a particular value from a file. After that I was bitwise OR'ing it with a few numbers to see what was up and assigning the result to a
BOOL
ean variable (which was connected to a checkbox). I forgot that if the value is anything other than 0, 1 or 2, the DDX routines will reset it to 0. DOH!!! Thanks to your advice of stepping through the code (why didn't I think of it myself?) I was able to spot it. Thanks again for listening to me and offering your suggestions. It helped me a lot. :) About doing the data transfer yourself, I avoid it as much as possible, because in most cases it's not necessary and I don't want to have to remember to do it each time. Data validation is a different game though. Best done by hand.
Regards,Rohit Sinha
Do not wait for leaders; do it alone, person to person.
- Mother Teresa