Solved

share variables between CView and CDialog?

Posted on 1998-06-10
3
264 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:kclemans
3 Comments
 
LVL 1

Accepted Solution

by:
TAMC earned 50 total points
ID: 1317836
If you create your dialog with DoModal() try this

CYourDialog dlg;
if(dlg.DoModal()==IDOK)
{
     m_viewvairable = dlg.m_dialogvariable;
}
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1317837
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

}


0
 

Author Comment

by:kclemans
ID: 1317838
Thanks, it worked.  Enjoy the points.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 101
How to create frequencies of a variable from SAS dataset? 10 125
EvenOdd challenge 10 109
scoreUp challenge 14 63
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question