Dynamic Control creation in dialog
I have created certain controls (static , edit etc.) dynamically using create in a dialog box OnInitDialog. When I try to close the dialog box I try to delete the dynamically created dialog boxes but application crashes and I also get following information in debug window.
CCmdTarget::~CCmdTarget() line 51 + 12 bytes
CWnd::~CWnd() line 766 + 15 bytes
CStatic::~CStatic() line 40 + 15 bytes
CStatic::`vector deleting destructor'
Please suggest from where I can delete these controls. I am deleteing the control array in following way.
delete[] m_pStatic;
delete[] m_pEdit;
Re: Dynamic Control creation in dialog
Quote:
Originally posted by Ashishu
I have created certain controls (static , edit etc.) dynamically using create in a dialog box OnInitDialog. When I try to close the dialog box I try to delete the dynamically created dialog boxes but application crashes and I also get following information in debug window.
CCmdTarget::~CCmdTarget() line 51 + 12 bytes
CWnd::~CWnd() line 766 + 15 bytes
CStatic::~CStatic() line 40 + 15 bytes
CStatic::`vector deleting destructor'
Please suggest from where I can delete these controls. I am deleteing the control array in following way.
delete[] m_pStatic;
delete[] m_pEdit;
I try to advice you
try to delete dynamic controls within handler of "Close" button
Try to delete before closing
Thanks
http://besonic.com/Vitaly
Re: Dynamic Control creation in dialog
Quote:
Originally posted by Ashishu
I have created certain controls (static , edit etc.) dynamically using create in a dialog box OnInitDialog. When I try to close the dialog box I try to delete the dynamically created dialog boxes but application crashes and I also get following information in debug window.
You say you are creating controls and deleting dialogs. I am confused.
Quote:
Originally posted by Ashishu
Please suggest from where I can delete these controls. I am deleteing the control array in following way.
delete[] m_pStatic;
delete[] m_pEdit;
You did not show how m_pStatic and m_pEdit are declared. That is important. In particular, are they arrays of pointers or arrays of the actual objectes?