Belthazor
asked on
Create a pointer to an existing Object....
How can I create a pointer to an existing Object?
I've got a class (CMyListCtrl) derived from CListCtrl. I want to call a non-static function of CMyProjectDialog, wich is the Dialog Class of my Project, out of CMyListCtrl. There's an Object of CMyListCtrl in CMyProjectDialog.
Thanks for help.
Belthazor
I've got a class (CMyListCtrl) derived from CListCtrl. I want to call a non-static function of CMyProjectDialog, wich is the Dialog Class of my Project, out of CMyListCtrl. There's an Object of CMyListCtrl in CMyProjectDialog.
Thanks for help.
Belthazor
Nothing more to say ...
ASKER
I dont want to call a Function of CListCtrl. I want to call a non-static function of CMyProjectDialog. In this class I've got an Object of CMyListCtrl. Now I want to call a function of CMyProjectDialog out of CMyListCtrl.
I hope this is a better description of my Problem.
I hope this is a better description of my Problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does CMyListCtrl have a pointer to CMyProjectDialog?
If not, you need to add a member variable to CMyListCtrl that is of a pointer type of CMyProjectDialog, and then have CMyProjectDialog initialize this variable via a function in CMyListCtrl.
If not, you need to add a member variable to CMyListCtrl that is of a pointer type of CMyProjectDialog, and then have CMyProjectDialog initialize this variable via a function in CMyListCtrl.
It looks like brazulewicz posted a similar method to my suggestion before my post went through.
I've had problems using brazulewicz method in the pass with VC++ 6.0. It doesn't like it when you use "this" in the initialize list.
An alternative method could be the following:
class CMyProjectDialog;
class CMyListCtrl
{
private:
CMyProjectDialog* parent;
public:
CMyListCtrl():parent(NULL)
{}
Initialize_CMyProjectDialo g(CMyProje ctDialog* aParent)
{
parent = aParent;
}
sampleMethod()
{
parent->sampleDialogMethod ();
}
}
class CMyProjectDialog
{
private:
CMyListCtrl list;
public:
CMyProjectDialog();
sampleDialogMethod();
};
CMyProjectDialog::CMyProje ctDialog()
{
list.Initialize_CMyProject Dialog(thi s)
}
I've had problems using brazulewicz method in the pass with VC++ 6.0. It doesn't like it when you use "this" in the initialize list.
An alternative method could be the following:
class CMyProjectDialog;
class CMyListCtrl
{
private:
CMyProjectDialog* parent;
public:
CMyListCtrl():parent(NULL)
{}
Initialize_CMyProjectDialo
{
parent = aParent;
}
sampleMethod()
{
parent->sampleDialogMethod
}
}
class CMyProjectDialog
{
private:
CMyListCtrl list;
public:
CMyProjectDialog();
sampleDialogMethod();
};
CMyProjectDialog::CMyProje
{
list.Initialize_CMyProject
}
it seems to me you have soled your problem.
ASKER
Thank you very much
CListCtrl::func();