RE: Resizable dialog
Hi guys,
Thank you for taking the time to answer my question.
The problem was that I had declared the second dialog as a member variable
of the first dialog class. I fixed it by declaring a pointer to the dialog as
the member variable and creating the dialog object just before displaying it.
Initially the code was something like this:
class CDlg1 : public CDialog
{
DECLARE_DYNAMIC(CDlg1)
public:
CDlg1(CWnd* pParent = NULL); // standard constructor
virtual ~CDlg1();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO *pMMI);
afx_msg void OnOK();
POINT m_MinSize;
int m_ButtonSeparation;
CDlg2 m_cDlg2;
DECLARE_MESSAGE_MAP()
};
I changed it to:
class CDlg1 : public CDialog
{
DECLARE_DYNAMIC(CDlg1)
public:
CDlg1(CWnd* pParent = NULL); // standard constructor
virtual ~CDlg1();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO *pMMI);
afx_msg void OnOK();
POINT m_MinSize;
int m_ButtonSeparation;
CDlg2 *m_pDlg2;
DECLARE_MESSAGE_MAP()
};
and then later on:
void CDlg1::OnOK()
{
m_pDlg2 = new CDlg2;
if (m_pDlg2)
{
m_pDlg2->DoModal();
delete m_pDlg2;
}
}
Posting this just in case someone else runs into the same problem.
Thanks,
Priya