Solved

CPropertySheets and parent dialogs

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 178
iSeries FTP Exit Program 8 136
zeroFront challenge 7 99
mapBully challenge 6 134
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 …
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 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