Solved

share variables between CView and CDialog?

Posted on 1998-06-10
3
246 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

759 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now