passing values b/w Dialog boxes
-
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??
-
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??
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.
-
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.
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
-
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
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.