Persist ActiveX Controls At Runtime

I was writing a piece of code to store and load user preferences and wanted to persist the properties of some ActiveX controls on my dialog. The following procedure seems to do the job rather nicely.

BOOL PersistActiveX(CArchive& ar, CWnd* pActiveX)


 // Create an archive stream
 CArchiveStream stm(&ar);
 LPUNKNOWN lpUnk = pActiveX->GetControlUnknown();

  // We have the IUnknown interface, so 
  // get the IPersistStreamInit

   // We have the relevant interface so load or save the data
   // based on the type of archive we have.
    hr = pPersStm->Load(&stm);
    hr = pPersStm->Save(&stm, FALSE);

  // Must release the interface

 return SUCCEEDED(hr);
This can then be called simply by doing the following:
PersistActiveX(ar, GetDlgItem(IDC_SOMEACTIVEX));


  • Persistence CArray in ActiveX

    Posted by Legacy on 01/18/2004 12:00am

    Originally posted by: Diego

    Do you know how can I save a CArray in to the persistance of the ActiveX - PX_Blob????


    • hello

      Posted by tqqttq on 05/30/2005 03:06am


  • Problem with successive serializing...

    Posted by Legacy on 09/14/2001 12:00am

    Originally posted by: Lez


    I'm using this function for serializing (loading) MFC ActiveX components. It Works great with the first component but i dont know why all others doesn't. It seems that the File (or the archive) is closing by the line pStream->Load(&stm).
    Does anyone have a solution ?

  • How to use Web Browser control in ATL?

    Posted by Legacy on 10/09/2000 12:00am

    Originally posted by: Peng Fei


    I need use Web Browser control in my ATL,
    but I cannot create the dialog with Web Browser.

    Please give me a solution.


  • Persist ActiveX Controls at Runtime

    Posted by Legacy on 02/28/2000 12:00am

    Originally posted by: kiran

    It is not mentioned as to how the CArchive object is created.

  • CArchiveStream

    Posted by Legacy on 02/21/2000 12:00am

    Originally posted by: Erling Eybye

    CArchiveStream ??? is this class a MFC class ?
    I can't find it on Microsoft's homepage.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

  • On-demand Event Event Date: September 23, 2015 The cloud is not just about a runtime platform for your projects – now, you can do your development in the cloud, too. Check out this webcast to learn how the cloud improves your development experience and team collaboration. Join Dana Singleterry, Principal Product Manager for Oracle Dev Tools, as he discusses how to simplify every aspect of the development lifecycle, including requirements gathering, version management, code reviews, build automation, and …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date