Solved

share variables between CView and CDialog?

Posted on 1998-06-10
3
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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