Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables.... 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how can i pass int's from one dialog to another dialog? without making a global int?
 
You can declare a public member variable or provide the variable through a ::getInt member function. The other solution is to declare the first dialog as a friend class of the second dialog.
Cheers,
Long.
 
if the second dialog is created in the first dialog, you cud do something like this.

// first dialog code.

CSecondDialog dialog (integer_Number);
..
...
dialog.DoModal ().
// end

note that when the second dialog is being created, pass the data to the constructor. You now need to modify the constructor in yr second dialog to accept this parameter.

Hope this helps
Sriks
 
Well, my favorite way it to make a pointer to the parent dialog box. Like so

CTheParentDlgBox * pPointer = (CTheParentDlgBox*)GetParent()

The command line initializing a pointer can be placed anywhere in your child box programming, as long as your child box is a direct dialog box of CTheParentDlgBox. This allows the child box access to public members (variables) of the parent dialog. To access these parent members just use the pointer like such:

pPointer->theVariable

Now your accessing variables from the parent dialog box. Be careful, the pPointer will also reassign values to the parents variable if you change them in child box. If you don't wish to change it in the parent box, but like to change the value in the child box. Make a new variable in the child box and assign the parents variable value to that of the childs variable, like so:

int childVariable = pPointer->theVariable.

Hope this helps you out some

Nyjil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top