Solved

CPropertySheets and parent dialogs

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

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 163
tripleUp challenge 7 92
My project did see openJDK that I installed. What could be the problem 7 161
Problem to App source 6 89
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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