[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

struct's

Posted on 2000-02-14
1
Medium Priority
?
297 Views
Last Modified: 2010-04-02
Hi, I have a dialog based MFC app with 4 property pages. I have twenty variables to pass between the property pages and my dialog box. What is the best way of doing this? I assume that placing the variables into a structure is the best way, but now how do I use it and pass it between my dialog box class and the property pages classes? Added information is that the variables are initialised and used in the dialog box class, but the property pages are used to altered the variables. If possible, please show me through a simple example how to pass the struct around, assuming of course that the struct is the best way to do this. More added information is that I have been using global variables to start off with, and I want to move away from this to the struct, or whatever. Thanks.
0
Comment
Question by:rose337
[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
1 Comment
 
LVL 1

Accepted Solution

by:
ScottyDawg earned 210 total points
ID: 2519079
The struct part is irrelevant for the time being.

Create your class derived from CPropertySheet and add to it all the member variables you wish to use – make sure they are declared as public:

Now each property page can look at its parent for the member variables. E.g.

Void Foo(int a, int b, in c)
{
      // Create the pages
      Cpage1 Page1;
      Cpage2 Page2;

      // Create the property sheet
      CmyPropertySheet MySheet;

      // Add the pages to the propertysheet
      MySheet.AddPage(&Page1);
      MySheet.AddPage(&Page2);

      // Initialise the variables
MySheet.a = a;
MySheet.b = b;
MySheet.c = c;

MySheet.DoModal();
}


Cpage1::OnDoSomething()
{
      CMySheet* pMySheet = (CMySheet*)GetParent;
      ASSERT(pMySheet);

      // access member vars via pMySheet
      pMySheet->a = pMySheet.b + pMySheet.c;
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

650 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