Solved

struct's

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 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.

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