Solved

EXTERN

Posted on 1998-11-24
2
210 Views
Last Modified: 2010-04-01
Hi... I have a dialog based MFC application with a button on it that opens a property sheet with four pages. I want to use a variable in the dialog and I want to use the same variable in  the property sheet. So if I have a variable x in the dialog, and I try to use it in the property sheet, I must be able to have the variables value. At the moment I am using the EXTERN definition. Is there another nicer way because I don't like EXTERN. Thanks
0
Comment
Question by:rose337
2 Comments
 
LVL 2

Accepted Solution

by:
cyrilbdt earned 50 total points
ID: 1178550
CMyDlg::OnButton1()
{
 CMyPropSheet sheet;
 CPage1 page1;
...
 page1.m_x = m_x;
 sheet.AddPage(&page1);
..
 if(sheet.DoModal() != IDOK)
  return;
 m_x = page1.m_x;
 .....
}


0
 
LVL 2

Expert Comment

by:rayb
ID: 1178551
No disrespect to cyrilbdt, but a slightly slicker method would be to write your pages to accept a pointer or a reference to your variable.  That way the pages can update the variable directly.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

760 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

20 Experts available now in Live!

Get 1:1 Help Now