Hello All,

I have a test application that dynamically creates ActiveX controls (based upon event fire), and stores pointers to them in a vector. I.e.

ActiveXControl *myControl = new ActiveXControl();
m_myControls.push_back(myControl); //Stores it to access in future

RECT rcLocal;
rcLocal = SetSize(rcLocal); //function that sets size of control to be created

BOOL bStat = myControl->CreateControl(pNewGlobe->GetClsid(), "", WS_VISIBLE, rcLocal, this, m_nNextControlId++, NULL, FALSE, NULL); //Creates control

myControl->SetWinID(nSceneID); //Sets the appropriate control with its window.

QUESTION:

I want to run this program, have all controls created (and then use them), and then allow the user to select to "Reset". This would wipe out all of the activeX controls and leave the application running, waiting for input for new Controls to be made.

How can I iterate through the list of current ActiveX controls, and delete them + resize window at same time?

I've tried:

for (unsigned int i = 0; i <m_myControls.size(); i++)
{
myControl= m_myControls[i];
int nCntrlID = myControl->GetDlgCtrlID();
pEdit = GetDlgItem(nCntrlID);
pEdit->DestroyWindow(); //Does not run through and remove the controls
//myControl->DestroyWindow();
//ResizeControls(); //<----Crashes
}

Any ideas are appreciated! Thanks!