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. problem with variable in 2 diferent dialog boxes

problem with variable in 2 diferent dialog boxes

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelpquestionlearning
10 Posts 2 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.
  • M Offline
    M Offline
    Mathieu Dijkstra
    wrote on last edited by
    #1

    :sigh:hi im new to windows programming and i am studiing the book in dutch so sorry for my bad english. problem is this: i can't get data from dialog box 1 in to dialog box 2 kan anny one tel me wy this is thank you verry much m.t. dijkstra this is the litle program www.palcopy.com/down_load/comunication_between_variabel_of_2_windows.zip you can down load it frome my home page the problem is in m_waardeChild = a box in the 2th window where the text must be displayed and m_TestOutput = a input box in the 1th window where you come in !!!! this is wat the second window must do if in the second dialog is kliked on buton problem then get input variabel frome 1 dialog en write it down in second window but it dos not work???? void CChildDialog::OnBUTTONproblem() { // TODO: Add your control notification handler code here // m_waardeChild = "this works"; // m_waardeChild = CComunicationbetweenvariabelof2windowsDlg.m_TestOutput;// dos not work // m_waardeChild = CComunicationbetweenvariabelof2windowsDlg->m_TestOutput;// dos not work m_waardeChild = CComunicationbetweenvariabelof2windowsDlg* m_TestOutput; // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE); } thank's verry much for helping -- modified at 15:35 Wednesday 9th November, 2005

    D 1 Reply Last reply
    0
    • M Mathieu Dijkstra

      :sigh:hi im new to windows programming and i am studiing the book in dutch so sorry for my bad english. problem is this: i can't get data from dialog box 1 in to dialog box 2 kan anny one tel me wy this is thank you verry much m.t. dijkstra this is the litle program www.palcopy.com/down_load/comunication_between_variabel_of_2_windows.zip you can down load it frome my home page the problem is in m_waardeChild = a box in the 2th window where the text must be displayed and m_TestOutput = a input box in the 1th window where you come in !!!! this is wat the second window must do if in the second dialog is kliked on buton problem then get input variabel frome 1 dialog en write it down in second window but it dos not work???? void CChildDialog::OnBUTTONproblem() { // TODO: Add your control notification handler code here // m_waardeChild = "this works"; // m_waardeChild = CComunicationbetweenvariabelof2windowsDlg.m_TestOutput;// dos not work // m_waardeChild = CComunicationbetweenvariabelof2windowsDlg->m_TestOutput;// dos not work m_waardeChild = CComunicationbetweenvariabelof2windowsDlg* m_TestOutput; // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE); } thank's verry much for helping -- modified at 15:35 Wednesday 9th November, 2005

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

      Which of these two best describes the relationship between the two dialogs? Are both dialogs owned by the same parent:

       parent
      /      \\
      

      dlg 1 dlg 2

      Or does one dialog own the other:

      parent
      |
      dlg 1
      |
      dlg 2


      "Take only what you need and leave the land as you found it." - Native American Proverb

      M 1 Reply Last reply
      0
      • D David Crow

        Which of these two best describes the relationship between the two dialogs? Are both dialogs owned by the same parent:

         parent
        /      \\
        

        dlg 1 dlg 2

        Or does one dialog own the other:

        parent
        |
        dlg 1
        |
        dlg 2


        "Take only what you need and leave the land as you found it." - Native American Proverb

        M Offline
        M Offline
        Mathieu Dijkstra
        wrote on last edited by
        #3

        parent | dlg 1 like this in parent there is a variabel in dlg there is a function who wil get the variabel frome the parent void CChildDialog::OnBUTTONproblem() { geting data frome dlg1 } how is this manegd thank's verry much for helping

        D 1 Reply Last reply
        0
        • M Mathieu Dijkstra

          parent | dlg 1 like this in parent there is a variabel in dlg there is a function who wil get the variabel frome the parent void CChildDialog::OnBUTTONproblem() { geting data frome dlg1 } how is this manegd thank's verry much for helping

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

          There are several ways to do this. The easiest, although not considered good OO practice, is to mark the variable as public in the parent class. Then in the child, simply call GetParent(). Or, mark the variable as private and use a get/set method instead. Also, you could add the same type of variable to the child, mark it as public, and assign it a value before calling the dialog's DoModal() method.


          "Take only what you need and leave the land as you found it." - Native American Proverb

          M 1 Reply Last reply
          0
          • D David Crow

            There are several ways to do this. The easiest, although not considered good OO practice, is to mark the variable as public in the parent class. Then in the child, simply call GetParent(). Or, mark the variable as private and use a get/set method instead. Also, you could add the same type of variable to the child, mark it as public, and assign it a value before calling the dialog's DoModal() method.


            "Take only what you need and leave the land as you found it." - Native American Proverb

            M Offline
            M Offline
            Mathieu Dijkstra
            wrote on last edited by
            #5

            m_TestOutput is in main window and is public this is standing in dialog 1 under buttonproblem void CChildDialog::OnBUTTONproblem() { CWnd *CParentWindow = GetParent();// Get pointer from parent window m_waardeChild = CParentWindow->m_TestOutput;// dos not work ether // // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE); } get folowing error --------------------Configuration: comunication between variabel of 2 windows - Win32 Debug-------------------- Compiling... ChildDialog.cpp c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(54) : error C2039: 'm_TestOutput' : is not a member of 'CWnd' c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd' Error executing cl.exe. comunication between variabel of 2 windows.exe - 1 error(s), 0 warning(s) thank's verry much for helping -- modified at 17:11 Wednesday 9th November, 2005

            M D 2 Replies Last reply
            0
            • M Mathieu Dijkstra

              m_TestOutput is in main window and is public this is standing in dialog 1 under buttonproblem void CChildDialog::OnBUTTONproblem() { CWnd *CParentWindow = GetParent();// Get pointer from parent window m_waardeChild = CParentWindow->m_TestOutput;// dos not work ether // // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE); } get folowing error --------------------Configuration: comunication between variabel of 2 windows - Win32 Debug-------------------- Compiling... ChildDialog.cpp c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(54) : error C2039: 'm_TestOutput' : is not a member of 'CWnd' c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd' Error executing cl.exe. comunication between variabel of 2 windows.exe - 1 error(s), 0 warning(s) thank's verry much for helping -- modified at 17:11 Wednesday 9th November, 2005

              M Offline
              M Offline
              Mathieu Dijkstra
              wrote on last edited by
              #6

              can any one help me whit this problem im a beginer in this thank's verry much for helping

              1 Reply Last reply
              0
              • M Mathieu Dijkstra

                m_TestOutput is in main window and is public this is standing in dialog 1 under buttonproblem void CChildDialog::OnBUTTONproblem() { CWnd *CParentWindow = GetParent();// Get pointer from parent window m_waardeChild = CParentWindow->m_TestOutput;// dos not work ether // // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE); } get folowing error --------------------Configuration: comunication between variabel of 2 windows - Win32 Debug-------------------- Compiling... ChildDialog.cpp c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(54) : error C2039: 'm_TestOutput' : is not a member of 'CWnd' c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd' Error executing cl.exe. comunication between variabel of 2 windows.exe - 1 error(s), 0 warning(s) thank's verry much for helping -- modified at 17:11 Wednesday 9th November, 2005

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

                Mathieu Dijkstra wrote:

                UpdateData(FALSE);

                My first suggestion would be to lose the calls to UpdateData(). They are unnecessary and will only confuse you further. Using SetWindowText() and GetWindowText() instead is much cleaner and less error-prone.

                Mathieu Dijkstra wrote:

                m_waardeChild = CParentWindow->m_TestOutput;// dos not work ether

                The compiler is telling you exactly what the problem is. Try:

                CComunicationbetweenvariabelof2windowsDlg *pParent;
                pParent = (CComunicationbetweenvariabelof2windowsDlg *) GetParent();
                m_waardeChild = pParent->m_TestOutput;


                "Take only what you need and leave the land as you found it." - Native American Proverb

                M 1 Reply Last reply
                0
                • D David Crow

                  Mathieu Dijkstra wrote:

                  UpdateData(FALSE);

                  My first suggestion would be to lose the calls to UpdateData(). They are unnecessary and will only confuse you further. Using SetWindowText() and GetWindowText() instead is much cleaner and less error-prone.

                  Mathieu Dijkstra wrote:

                  m_waardeChild = CParentWindow->m_TestOutput;// dos not work ether

                  The compiler is telling you exactly what the problem is. Try:

                  CComunicationbetweenvariabelof2windowsDlg *pParent;
                  pParent = (CComunicationbetweenvariabelof2windowsDlg *) GetParent();
                  m_waardeChild = pParent->m_TestOutput;


                  "Take only what you need and leave the land as you found it." - Native American Proverb

                  M Offline
                  M Offline
                  Mathieu Dijkstra
                  wrote on last edited by
                  #8

                  :doh:wel i tryd it and it wont work this is wat i dit in the function -------------------------------------------- void CChildDialog::OnBUTTONproblem() { // TODO: Add your control notification handler code here CComunicationbetweenvariabelof2windowsDlg *pParent; pParent = (CComunicationbetweenvariabelof2windowsDlg *) GetParent(); m_waardeChild = pParent->m_TestOutput; // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE);// to put data on screen (i wil change it in the future to SetWindowText() must first look how it works i think somthing like this but not tested SetWindowText(m_waardeChild); // but as usual c++ wil say it's wrong } ------------------------------------------------------------------------------- message by visual c++6 = --------------------Configuration: comunication between variabel of 2 windows - Win32 Debug-------------------- Compiling... ChildDialog.cpp c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'CComunicationbetweenvariabelof2windowsDlg' : undeclared identifier c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'pParent' : undeclared identifier c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : warning C4552: '*' : operator has no effect; expected operator with side-effect c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(61) : error C2059: syntax error : ')' c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(62) : error C2227: left of '->m_TestOutput' must point to class/struct/union Error executing cl.exe. comunication between variabel of 2 windows.exe - 4 error(s), 1 warning(s) :( thank's verry much for helping

                  D 1 Reply Last reply
                  0
                  • M Mathieu Dijkstra

                    :doh:wel i tryd it and it wont work this is wat i dit in the function -------------------------------------------- void CChildDialog::OnBUTTONproblem() { // TODO: Add your control notification handler code here CComunicationbetweenvariabelof2windowsDlg *pParent; pParent = (CComunicationbetweenvariabelof2windowsDlg *) GetParent(); m_waardeChild = pParent->m_TestOutput; // can anny one tel me how this works in c++ i dont understand // to get data from the other window up in here????? UpdateData(FALSE);// to put data on screen (i wil change it in the future to SetWindowText() must first look how it works i think somthing like this but not tested SetWindowText(m_waardeChild); // but as usual c++ wil say it's wrong } ------------------------------------------------------------------------------- message by visual c++6 = --------------------Configuration: comunication between variabel of 2 windows - Win32 Debug-------------------- Compiling... ChildDialog.cpp c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'CComunicationbetweenvariabelof2windowsDlg' : undeclared identifier c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'pParent' : undeclared identifier c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : warning C4552: '*' : operator has no effect; expected operator with side-effect c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(61) : error C2059: syntax error : ')' c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(62) : error C2227: left of '->m_TestOutput' must point to class/struct/union Error executing cl.exe. comunication between variabel of 2 windows.exe - 4 error(s), 1 warning(s) :( thank's verry much for helping

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

                    Mathieu Dijkstra wrote:

                    c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'CComunicationbetweenvariabelof2windowsDlg' : undeclared identifier

                    Again, the compiler is telling you the problem. You have referenced an identifier that has not been declared. You need to include Comunicationbetweenvariabelof2windowsDlg.h at the top of ChildDialog.cpp.


                    "Take only what you need and leave the land as you found it." - Native American Proverb

                    M 1 Reply Last reply
                    0
                    • D David Crow

                      Mathieu Dijkstra wrote:

                      c:\sevc6\comunication between variabel of 2 windows\ChildDialog.cpp(60) : error C2065: 'CComunicationbetweenvariabelof2windowsDlg' : undeclared identifier

                      Again, the compiler is telling you the problem. You have referenced an identifier that has not been declared. You need to include Comunicationbetweenvariabelof2windowsDlg.h at the top of ChildDialog.cpp.


                      "Take only what you need and leave the land as you found it." - Native American Proverb

                      M Offline
                      M Offline
                      Mathieu Dijkstra
                      wrote on last edited by
                      #10

                      cool that was the problem many thanks 4 helping me wit my study on variabels and multy dialogs :):):):):):):):):):):):):):):):):):):):) problem is solved i go studithis verry carful becorse i was having a problem whit this over 1 year many thanks;) waw you are a supper coder (by the way i had this problem also on a dutch formum but they dit not solve it) thanks agen

                      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