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 b/w Dialog boxes

passing values b/w Dialog boxes

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • U Offline
    U Offline
    User 2070738
    wrote on last edited by
    #1

    I want to pass member variable values b/w different dialog boxes of my application.How I do that....do I have to make one dialog box class parent of another??how i do that??

    K 1 Reply Last reply
    0
    • U User 2070738

      I want to pass member variable values b/w different dialog boxes of my application.How I do that....do I have to make one dialog box class parent of another??how i do that??

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      The parent dialog or window is the one that comes in first and gets out last. It creates other dialogs, windows etc. My bit-weird way would be: Make pointer-variables for each of shared variables in the parent. Assign them the address of the variable in the child dialog when creating the dialog. E.g. class CParent { int* m_pVariable; }; CChild* c; c = new CChild; m_pVariable = &c->m_Variable;//put the address of the variable in parent when creating the child. Now... class CSecondChild { int* m_pVar; }; CSecondChild* cc; cc = new CSecondChild; cc->m_pVar = m_pVariable; Here, the value in CSecondChild::m_pVar is the value of the variable CChild::m_Variable. When you change m_Variable in CChild, it is reflected in CSecondChild's m_pVar. My code is confusing I think. this is this.

      U 1 Reply Last reply
      0
      • K khan

        The parent dialog or window is the one that comes in first and gets out last. It creates other dialogs, windows etc. My bit-weird way would be: Make pointer-variables for each of shared variables in the parent. Assign them the address of the variable in the child dialog when creating the dialog. E.g. class CParent { int* m_pVariable; }; CChild* c; c = new CChild; m_pVariable = &c->m_Variable;//put the address of the variable in parent when creating the child. Now... class CSecondChild { int* m_pVar; }; CSecondChild* cc; cc = new CSecondChild; cc->m_pVar = m_pVariable; Here, the value in CSecondChild::m_pVar is the value of the variable CChild::m_Variable. When you change m_Variable in CChild, it is reflected in CSecondChild's m_pVar. My code is confusing I think. this is this.

        U Offline
        U Offline
        User 2070738
        wrote on last edited by
        #3

        jee haan app ka code is definitly cofusing....dont u think this can be done by making one dialog class parent of another....Ive done this and it works...but the problem is that I want to pass all the values of child dialogs back to the main dialog. Thanx for the reply AH

        K 1 Reply Last reply
        0
        • U User 2070738

          jee haan app ka code is definitly cofusing....dont u think this can be done by making one dialog class parent of another....Ive done this and it works...but the problem is that I want to pass all the values of child dialogs back to the main dialog. Thanx for the reply AH

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

          I don't exacly get your point. Do you have all child dialogs visible at the same time, or is it DoModal() for each child dialog? If you are using DoModal() for each child, then get the data from each of them: CChild c; if (c.DoModal() == IDOK) { int a = c.m_Variable; //Do this for all variables you need. ... } this is this.

          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