Solved

CPropertySheets and parent dialogs

Posted on 2003-11-25
4
222 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 58
fizzArray2 challenge 1 61
pre4 challenge 19 88
mapBully challenge 6 93
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now