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;