HOWTO: Saving a Blob Property in ActiveX Control Pad

ID: Q167827


The information in this article applies to:


SUMMARY

Writing out a blob property using PX_Blob() may not work when the control is hosted in an HTML page in ActiveX Control Pad. The blob property is not written out when the HTML page is saved.

The solution is to throw an exception if PX_Blob returns FALSE as follows:


   void CCircCtrl::DoPropExchange(CPropExchange* pPX)
   {
   ...
      if (!PX_Blob(pPX, _T("CircleOffset"), hOffset))
          AfxThrowOleException (E_FAIL);
   ...
   } 


MORE INFORMATION

When it comes time to save out the control's properties, first ActiveX Control Pad calls the control's IPersistPropertyBag::Save() function which in turn calls DoPropExchange(). If PX_Blob() returns FALSE in DoPropExchange(), it throws an exception. The exception is caught by COleControl::XPersistPropertyBag::Save() and E_FAIL is returned. This prompts ActiveX Control Pad to call the control's IPersistStream::Save() function which can write out the blob property.

The binary or blob property is saved in the <OBJECT> tag under the DATA attribute:


   <OBJECT ID="Circ1" CLASSID="CLSID:2ACAA944-C431-11CF-8E0E-00AA00B91033"
   DATA="DATA:application/x-oleobject;BASE64,...">
   </OBJECT> 


REFERENCES

For a sample control that writes out a blob property, please see the following article(s) in the Microsoft Knowledge Base:

Q137333 DOC: How To Use the PX_Blob Function

Additional query words:


Keywords          : kbcode kbole kbActiveX kbMFC kbVC kbVC400 kbVC410 kbVC420 kbVC500 AXSDKControls 
Version           : 1.0 4.0 4.1 4.2 5.0
Platform          : NT WINDOWS 
Issue type        : kbhowto 

Last Reviewed: July 29, 1999