Re: Overloaded constructor issues in MFC Dialogs
On Feb 15, 10:05 pm, Brad Gillespie <Brad
Gilles...@discussions.microsoft.com> wrote:
Thus far, I have been creating classes that have objects in the header fi=
le.
E.g., I might create a dialog box class, and in the *.h file for the dial=
og
box class, I have instantiated various objects, such as tab controls or l=
ist
controls, etc. So the dialog class =93has-a=94 list control, for insta=
nce.
However, I have run into a severe limitation. I can't use alternativ=
e
constructors (Overloaded Constructors) when doing this, because I can't
include any pass parameters when instantiating an object in the *.h file =
of
some other class.
Let me clarify. If I create a dialog class called DialogA, then in the=
*.h
file for that class, I cannot instantiate a member object by passing
variables to the constructor of that object's class. That is, in the
DialogA.h file,
CMyListCtrl ListCtrlObj; //=
I can say this
CMyListCtrl ListCtrlObj(123,'M'); // I can't say thi=
s
It looks like you are looking for this:
header:
class CMyDialog : public CDialog
{
public:
CMyDialog(CWnd* pParent, int listParam1, char ListParam2);
}
implementation (or inline):
CMyDialog::CMyDialog(CWnd* pParent, int listParam1, char listParam2) :
CDialog(IDD, pParent), ListCtrlObj(listParam1, listParam2)
{}
Please don't take offense, but it also looks like you should not be
using MFC yet, you should instead learn more about the language
itself.
Goran.