Solved

CPropertySheets and parent dialogs

Posted on 2003-11-25
4
229 Views
Last Modified: 2013-11-20
Hi All,

I have a Parent CDialog.

This CDialog has a CPropertyPage

The CPropertyPage has two CPropertySheets

Now be it due to necessity or bad design on my part, i need to call a method (update some controls) on the parent CDialog from within my CPropertySheet.

The CPropertySheets are static CDialogs which are now inherited from CPropertySheet.

I have thought of passing the 'this' parameter in the property sheet constructor, but I get a circular error with the include files.

What would be the easiest solution for calling a member function of my parent CDialog from my CPropertySheet


Txs
0
Comment
Question by:Pete2003
[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
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9818648
Depends a bit on how the classes are defined. If in one class only pointer needs to be known a simple forward declaration is sufficient:
class CMyDialog;
class CMyPropertySheet {
};

Is there a guard around the header file?
#ifndef filename_h
#define filename_h

header file content.

#endif

This prevents the file from beeing included twice. I think the guard should always be present.

Do you really need a method of the parent to be called or would it be sufficient to post the parent a message?
0
 

Author Comment

by:Pete2003
ID: 9823103
There is a guard already ... but because I'm using pointers to the classes inside the child classes the parent class is then undefined.

My question was however more specific. How can I make calls on the PropertyPage or even the parent dialog from the property sheet
0
 
LVL 13

Accepted Solution

by:
SteH earned 125 total points
ID: 9823148
To get rid of the undefined class you can use forward declaration. The following compiles without problems.

class b;  // forward declaration for class b. In case of a 2 header files have it before either class.
class a    // In class a you can now use a pointer to class b.
{
public:
    a () {};
    ~a () {};
    double funa (double d1);
    class b* pb;
};

class b
{
public:
    b () {};
    ~b () {};
    int funb (int i1);
    class a* pa;
};

double a::funa (double d1) {
    return d1 * .5;
}

int b::funb (int i1) {
    return i1 + 5;
}

Another approach is to post a (user defined) message to the main wnd (= parent dlg) or the parent wnd (=PropertyPage):


0
 

Author Comment

by:Pete2003
ID: 9823760
Ok that wan't really help me since both these classes inherit from diffrent places so it's a bit more complicated, so I'll have to redesign ...  but here are the points anyway :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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