Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Stupid problem

Stupid problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rohit Sinha
    wrote on last edited by
    #1

    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. After ReadSettings() (my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this function UpdateData(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 after UpdateData() the value of the variable is also somehow set to FALSE 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 during UpdateData(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

    J T D 3 Replies Last reply
    0
    • R Rohit Sinha

      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. After ReadSettings() (my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this function UpdateData(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 after UpdateData() the value of the variable is also somehow set to FALSE 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 during UpdateData(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

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      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?!?

      R 1 Reply Last reply
      0
      • R Rohit Sinha

        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. After ReadSettings() (my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this function UpdateData(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 after UpdateData() the value of the variable is also somehow set to FALSE 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 during UpdateData(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

        T Offline
        T Offline
        Ted Ferenc
        wrote on last edited by
        #3

        Souns 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

        1 Reply Last reply
        0
        • R Rohit Sinha

          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. After ReadSettings() (my function which reads the settings and puts them in variables), the values are just what they should be. At the end of this function UpdateData(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 after UpdateData() the value of the variable is also somehow set to FALSE 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 during UpdateData(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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          You're likely to solve the problem by using member control variables instead of UpdateData(). See jhwurmbach's comment.

          1 Reply Last reply
          0
          • J jhwurmbach

            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?!?

            R Offline
            R Offline
            Rohit Sinha
            wrote on last edited by
            #5

            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 BOOLean 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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups