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. DoDataExchange doesn't like pointers ?

DoDataExchange doesn't like pointers ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresquestionlearning
9 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.
  • C Offline
    C Offline
    cagespear
    wrote on last edited by
    #1

    If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage

    C D H 3 Replies Last reply
    0
    • C cagespear

      If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      cagespear wrote:

      The program asserts

      Why? I.e. what was the assertion message?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      1 Reply Last reply
      0
      • C cagespear

        If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage

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

        Are you creating the CEdit object and calling Create() before or after calling CDialog::OnInitDialog()?

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        C 1 Reply Last reply
        0
        • D David Crow

          Are you creating the CEdit object and calling Create() before or after calling CDialog::OnInitDialog()?

          "Love people and use things, not love things and use people." - Unknown

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          C Offline
          C Offline
          cagespear
          wrote on last edited by
          #4

          No, what's the need of that if I am doing DDX_Control?

          D 1 Reply Last reply
          0
          • C cagespear

            No, what's the need of that if I am doing DDX_Control?

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

            cagespear wrote:

            No

            It was not a yes/no question.

            cagespear wrote:

            what's the need of that if I am doing DDX_Control?

            It's required. Now, where is the call to CDialog::OnInitDialog() in relation to where the CEdit object is created and its Create() method called?

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C 1 Reply Last reply
            0
            • C cagespear

              If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via DDX_Control(IDC_EDIT_BOX, *pEdit); The program asserts. It works fine if I create a CEdit object on stack and pass it. Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me :( Thanks Cage

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Do you want to make dynamic editbox and use of their events?

              1 Reply Last reply
              0
              • D David Crow

                cagespear wrote:

                No

                It was not a yes/no question.

                cagespear wrote:

                what's the need of that if I am doing DDX_Control?

                It's required. Now, where is the call to CDialog::OnInitDialog() in relation to where the CEdit object is created and its Create() method called?

                "Love people and use things, not love things and use people." - Unknown

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                C Offline
                C Offline
                cagespear
                wrote on last edited by
                #7

                I don't think so david. I am pretty sure I don't need an explicit create call in my oninitdialog if I am linking the editbox with the dialog with DDX_Control call. As it turned out, it was an issue with the resource ID.Thanks for the advice though. Regards Cage

                D 1 Reply Last reply
                0
                • C cagespear

                  I don't think so david. I am pretty sure I don't need an explicit create call in my oninitdialog if I am linking the editbox with the dialog with DDX_Control call. As it turned out, it was an issue with the resource ID.Thanks for the advice though. Regards Cage

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

                  cagespear wrote:

                  I am pretty sure I don't need an explicit create call in my oninitdialog...

                  Correct. But the CEdit object must be created before CDialog::OnInitDialog() is called. Otherwise, DDX_Control() will throw an exception.

                  "Love people and use things, not love things and use people." - Unknown

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  C 1 Reply Last reply
                  0
                  • D David Crow

                    cagespear wrote:

                    I am pretty sure I don't need an explicit create call in my oninitdialog...

                    Correct. But the CEdit object must be created before CDialog::OnInitDialog() is called. Otherwise, DDX_Control() will throw an exception.

                    "Love people and use things, not love things and use people." - Unknown

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    C Offline
                    C Offline
                    cagespear
                    wrote on last edited by
                    #9

                    Agreed :)

                    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