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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dialog Data Exchange

Dialog Data Exchange

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • K Offline
    K Offline
    Kash
    wrote on last edited by
    #1

    Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers. void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); } Have I missed something out? kash

    J P 2 Replies Last reply
    0
    • K Kash

      Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers. void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); } Have I missed something out? kash

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

      Kash wrote: Have I missed something out? Yep! MSDN[^]says:

      The framework automatically calls UpdateData
      with bSaveAndValidate set to FALSE when a modal
      dialog box is created in the default implementation
      of CDialog::OnInitDialog. The call occurs before
      the dialog box is visible. The default
      implementation of CDialog::OnOK calls this member
      function with bSaveAndValidate set to TRUE to
      retrieve the data, and if successful, will close
      the dialog box.

      So you Do not have to call UpdataData() yourself:

      void CMyPropPage::OnCallMyDlgButton()
      {
      CMyDlg ViewData;
      if (ViewData.DoModal()==IDOK)
      m_Number = ViewData.m_Number;
      }


      My opinions may have changed, but not the fact that I am right.

      K 1 Reply Last reply
      0
      • K Kash

        Hi, I am calling a Dialog box from a propery page. The dialog box contains an edit box which takes in numbers as user inputs. I then want these numbers to be used on the property page. However, as I "OK" the dialog box and go back to it, the numbers have changed back to what the constructor contains. I have used UpdataData(TRUE); but it continues to revert back to the original numbers. void CMyPropPage::OnCallMyDlgButton() { UpdateData(TRUE); CMyDlg ViewData; ViewData.DoModal(); UpdateData(FALSE); } Have I missed something out? kash

        P Offline
        P Offline
        palbano
        wrote on last edited by
        #3

        CMyDlg ViewData; ViewData.m_number = 10; // set data to previous value ViewData.DoModal(); m_viewdatanumber = ViewData.m_number; // capture data from dialog

        "No matter where you go, there your are..." - Buckaoo Banzi

        -pete

        K 1 Reply Last reply
        0
        • J jhwurmbach

          Kash wrote: Have I missed something out? Yep! MSDN[^]says:

          The framework automatically calls UpdateData
          with bSaveAndValidate set to FALSE when a modal
          dialog box is created in the default implementation
          of CDialog::OnInitDialog. The call occurs before
          the dialog box is visible. The default
          implementation of CDialog::OnOK calls this member
          function with bSaveAndValidate set to TRUE to
          retrieve the data, and if successful, will close
          the dialog box.

          So you Do not have to call UpdataData() yourself:

          void CMyPropPage::OnCallMyDlgButton()
          {
          CMyDlg ViewData;
          if (ViewData.DoModal()==IDOK)
          m_Number = ViewData.m_Number;
          }


          My opinions may have changed, but not the fact that I am right.

          K Offline
          K Offline
          Kash
          wrote on last edited by
          #4

          yep that works, but when I re-open the dialog box, the changes have been lost. I want to keep the changes fixed and not for it to revert to the constructor values of the dlg box. kash

          J 1 Reply Last reply
          0
          • K Kash

            yep that works, but when I re-open the dialog box, the changes have been lost. I want to keep the changes fixed and not for it to revert to the constructor values of the dlg box. kash

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

            Kash wrote: I want to keep the changes Then you can set the desired value before the DoModal(), as palbano suggested.


            My opinions may have changed, but not the fact that I am right.

            1 Reply Last reply
            0
            • P palbano

              CMyDlg ViewData; ViewData.m_number = 10; // set data to previous value ViewData.DoModal(); m_viewdatanumber = ViewData.m_number; // capture data from dialog

              "No matter where you go, there your are..." - Buckaoo Banzi

              -pete

              K Offline
              K Offline
              Kash
              wrote on last edited by
              #6

              Thanks, all works fine.

              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