MFC ..get a value from a previous dialog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eihabisaac
    New Member
    • Aug 2007
    • 38

    MFC ..get a value from a previous dialog

    hello all

    im new at MFC windows programming and i have a problem,,

    how can i get a value from a edit box in a dialog to use it in another dialog after clicking a button

    every dialog has its own class

    what should i do ?!

    thanks
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Try GetWindowText to get the data from the edit box and SetWindowText to put the data into another control.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      If you are using MFC then you may have (or want to) assigned data members in your class that automatically get updated with the values of the control. For an edit box this could be a CString or and int or UINT.

      If you have added these variables to you class, through the class wizard (under the class variables tab), they will have automatically been made public (MFC is bad for that) and even when the dialog box is closed while the instance of the class still exists you can access those variables thus accessing the data that the dialogue contained when the OK button was pressed.

      Write a constructor for your second class that takes the parameters to initialise your class variables so that you get to initialise the data that is used initialise the dialogue box controls.

      Alternatively between creating the class and calling DoModal set those variables.

      Comment

      • eihabisaac
        New Member
        • Aug 2007
        • 38

        #4
        thnks everybody ,, i found this information so helpfull but i still can't get the idea, i will try to search more and read more.. thanks anyway

        Comment

        Working...