Link to home
Start Free TrialLog in
Avatar of kclemans
kclemans

asked on

share variables between CView and CDialog?

how do i share a variable that is declared in the dialog class, with my cview class.  I need to do this because the variable is a member variable for a group of radio buttons in my dialog class.  Thanks
ASKER CERTIFIED SOLUTION
Avatar of TAMC
TAMC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kinkajou
kinkajou

The easiest thing is to make a global variable in you CView class .CPP file and use an extern in the dialog class .CPP file and place the value of the member variable in the shared variable. Example (which uses and int variable):

In CVIEW.CPP:

int ExampleVariable; // place at the top of the file under preprocessor definitions/#includes etc.


In DIALOG.CPP:

extern int ExampleVariable;// place at the top of the file under preprocessor definitions/#includes etc.
.
void DIALOGCLASS::SomeFunction ()
{
ExampleVariable = m_nMemberVariable; // m_nMemberVariable is a member variable of the DIALOGCLASS

}


Avatar of kclemans

ASKER

Thanks, it worked.  Enjoy the points.