Solved

EXTERN

Posted on 1998-11-24
2
230 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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