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. Passing values from one Dialog to Another.

Passing values from one Dialog to Another.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
10 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.
  • P Offline
    P Offline
    parichaybp
    wrote on last edited by
    #1

    Hi,, In my Project I have main Dialog DesktopSearchDlg CreateDlg & UpdateDlg. In CreateDlg I am accepting File Name on Ok I have to add the file name to UpdateDlg in a combo box Can any one please tell me how to do this. CreateDlg UpdateDlg File Name onOK ( ) ComboBox Regards, Parichay.

    K H 2 Replies Last reply
    0
    • P parichaybp

      Hi,, In my Project I have main Dialog DesktopSearchDlg CreateDlg & UpdateDlg. In CreateDlg I am accepting File Name on Ok I have to add the file name to UpdateDlg in a combo box Can any one please tell me how to do this. CreateDlg UpdateDlg File Name onOK ( ) ComboBox Regards, Parichay.

      K Offline
      K Offline
      kiran janaswamy
      wrote on last edited by
      #2

      hi, steps to capture the filename from the first dialog (CreateDlg) 1) store the Filename in the CString Variable before the Ok Button was Pressed. 2) In OnInitDialog of the Second Dialog i mean (UpdateDlg) create a an Object of the First Dialog (CreateDialog) : //============================================================== (ie) CreateDialog *mpmain = (CreateDialog *)GetParent(); CString str = mpmain->filenamemembervarialbe; ComboBox.Addstring(str); //Adding to ComboBox in SecondDialog //============================================================== over, Good Luck. uday. uday kiran

      P 1 Reply Last reply
      0
      • P parichaybp

        Hi,, In my Project I have main Dialog DesktopSearchDlg CreateDlg & UpdateDlg. In CreateDlg I am accepting File Name on Ok I have to add the file name to UpdateDlg in a combo box Can any one please tell me how to do this. CreateDlg UpdateDlg File Name onOK ( ) ComboBox Regards, Parichay.

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

        Hope I understood your question if you need to value or variable from DesktopSearchDlg in CreateDlg http://www.codeproject.com/script/comments/forums.asp?msg=1447977&forumid=1647&XtraIDs=1647&searchkw=Getparent&sd=1%2F25%2F2005&ed=4%2F25%2F2006#xx1447977xx[^]

        P 1 Reply Last reply
        0
        • K kiran janaswamy

          hi, steps to capture the filename from the first dialog (CreateDlg) 1) store the Filename in the CString Variable before the Ok Button was Pressed. 2) In OnInitDialog of the Second Dialog i mean (UpdateDlg) create a an Object of the First Dialog (CreateDialog) : //============================================================== (ie) CreateDialog *mpmain = (CreateDialog *)GetParent(); CString str = mpmain->filenamemembervarialbe; ComboBox.Addstring(str); //Adding to ComboBox in SecondDialog //============================================================== over, Good Luck. uday. uday kiran

          P Offline
          P Offline
          parichaybp
          wrote on last edited by
          #4

          Hi, Thanks for the reply.. I just store the file name as below void CCreateDlg::OnOk() { CString fname; fname=m_FILE_NAME; -- --- --- } Now in the UpdateDlg In the BOOL CUpdateDlg::OnInitDialog() { } ---- I want to know what is *mpmain ??? is this MainDialog window ???

          K 1 Reply Last reply
          0
          • P parichaybp

            Hi, Thanks for the reply.. I just store the file name as below void CCreateDlg::OnOk() { CString fname; fname=m_FILE_NAME; -- --- --- } Now in the UpdateDlg In the BOOL CUpdateDlg::OnInitDialog() { } ---- I want to know what is *mpmain ??? is this MainDialog window ???

            K Offline
            K Offline
            kiran janaswamy
            wrote on last edited by
            #5

            hi, yes it is Main Window Dialog you are correct. also when you want to access the Mainwindow Dialog in second dialog dont forget to include the first dialog header in second dialog. ie (i mean) # include "firstDialog.h" in the second Dialog. good luck. uday. uday kiran

            P 1 Reply Last reply
            0
            • K kiran janaswamy

              hi, yes it is Main Window Dialog you are correct. also when you want to access the Mainwindow Dialog in second dialog dont forget to include the first dialog header in second dialog. ie (i mean) # include "firstDialog.h" in the second Dialog. good luck. uday. uday kiran

              P Offline
              P Offline
              parichaybp
              wrote on last edited by
              #6

              Hi, I am bit confused now. In my project the main Dialog is CDesktopSearchDlg after that i have CreateDlg & UpdateDlg. //Uday firstDialog.h" in the second Dialog. // i want to which is first dialog and which is 2nd dialog. Is this code below correct ?? BOOL CUpdateDlg::OnInitDialog() { CDialog::OnInitDialog(); CreateDlg *CDesktopSearchDlg = (CreateDlg *)GetParent(); CString str = CDesktopSearchDlg->fname; m_UPDATE_FILE_NAME_COMBO.AddString(str); }

              K 1 Reply Last reply
              0
              • H Hamid Taebi

                Hope I understood your question if you need to value or variable from DesktopSearchDlg in CreateDlg http://www.codeproject.com/script/comments/forums.asp?msg=1447977&forumid=1647&XtraIDs=1647&searchkw=Getparent&sd=1%2F25%2F2005&ed=4%2F25%2F2006#xx1447977xx[^]

                P Offline
                P Offline
                parichaybp
                wrote on last edited by
                #7

                can u please tell what is the error ??? -> error CCreateDlg *CCreateDlg = (CCreateDlg*)GetParent(); CString str = CCreateDlg -> fname; m_UPDATE_FILE_NAME_COMBO.AddString(str); --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp D:\Parichay\DS with Help\DesktopSearch\UpdateDlg.cpp(146) : error C2059: syntax error : ')' Error executing cl.exe. DesktopSearch.exe - 1 error(s), 0 warning(s)

                K 1 Reply Last reply
                0
                • P parichaybp

                  Hi, I am bit confused now. In my project the main Dialog is CDesktopSearchDlg after that i have CreateDlg & UpdateDlg. //Uday firstDialog.h" in the second Dialog. // i want to which is first dialog and which is 2nd dialog. Is this code below correct ?? BOOL CUpdateDlg::OnInitDialog() { CDialog::OnInitDialog(); CreateDlg *CDesktopSearchDlg = (CreateDlg *)GetParent(); CString str = CDesktopSearchDlg->fname; m_UPDATE_FILE_NAME_COMBO.AddString(str); }

                  K Offline
                  K Offline
                  kiran janaswamy
                  wrote on last edited by
                  #8

                  hi, there is no confusion at all, from which dialog you want to access the control values ((ie) the String value of the File Name) just create an instance of the dialog and access the control values. good luck. uday. uday kiran

                  P 1 Reply Last reply
                  0
                  • K kiran janaswamy

                    hi, there is no confusion at all, from which dialog you want to access the control values ((ie) the String value of the File Name) just create an instance of the dialog and access the control values. good luck. uday. uday kiran

                    P Offline
                    P Offline
                    parichaybp
                    wrote on last edited by
                    #9

                    can u please tell what is the error ??? is this below code correct??? -> error CCreateDlg *CCreateDlg = (CCreateDlg*)GetParent(); CString str = CCreateDlg -> fname; m_UPDATE_FILE_NAME_COMBO.AddString(str); --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp D:\Parichay\DS with Help\DesktopSearch\UpdateDlg.cpp(146) : error C2059: syntax error : ')' Error executing cl.exe. DesktopSearch.exe - 1 error(s), 0 warning(s)

                    1 Reply Last reply
                    0
                    • P parichaybp

                      can u please tell what is the error ??? -> error CCreateDlg *CCreateDlg = (CCreateDlg*)GetParent(); CString str = CCreateDlg -> fname; m_UPDATE_FILE_NAME_COMBO.AddString(str); --------------------Configuration: DesktopSearch - Win32 Debug-------------------- Compiling... UpdateDlg.cpp D:\Parichay\DS with Help\DesktopSearch\UpdateDlg.cpp(146) : error C2059: syntax error : ')' Error executing cl.exe. DesktopSearch.exe - 1 error(s), 0 warning(s)

                      K Offline
                      K Offline
                      kiran janaswamy
                      wrote on last edited by
                      #10

                      hi parichay, change the Class instance and Class to Different values. you are using CCreateDlg class name and Member varible as same which is confusing. please change the values as //========================================================================== CreateDlg *pCreateDlg = (CreateDlg *) GetParent(); CString szStr = pCreateDlg->fname; //========================================================================== check with it. good luck, uday. uday kiran

                      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