C++, MFC: Supplying constructor arguments to a CDialog derived class correctly
Posted on 2007-11-20
I would like to supply a constructor argument to a wizard-generated CDialog derived class in MFC. This is the natural way to do it, because the dialog's content is predicated on a single seed value (an integer).
CMyDialog TheDialog(5); // TheDialog is instantiated
I see that wizard generated code for CDialog derived classed supplies a constructor like this:
CMyDialog ::CMyDialog (CWnd* pParent /*=NULL*/)
: CDialog(CMyDialog ::IDD, pParent)
I would like to instantiate this variable as above, with a particular class member integer's value initiated as described.
CMyDialog::CMyDialog (CWnd* pParent /*=NULL*/,int sku_is)
: CDialog(CEditExistingProductDialog::IDD, pParent)
sku = sku_is; // sku is the class member
causes an assertion failure when I supply CWnd* pParent as "this" (from anothe CDialog derived class), or if I supply NULL.
How should I go about getting this thing to work as described?