Solved

struct's

Posted on 2000-02-14
1
293 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 70 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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