Solved

CPropertySheets and parent dialogs

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

911 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

18 Experts available now in Live!

Get 1:1 Help Now