CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    3

    ActiveX Controls (Delete/Reset)

    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!

  2. #2
    Join Date
    May 2010
    Posts
    33

    Re: ActiveX Controls (Delete/Reset)

    You need to call the destructor of ActiveX controls before window's destructor

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: ActiveX Controls (Delete/Reset)

    Are you familiar with IUnknown::Release() method?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured