Microsoft KB Archive/167827

{|
 * width="100%"|

HOWTO: Saving a Blob Property in ActiveX Control Pad

 * }

Q167827

-

The information in this article applies to:


 * The Microsoft Foundation Classes (MFC), used with:
 * Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.0a, 4.1, 4.2, 4.2b, 5.0
 * Microsoft ActiveX Control Pad, version 1.0
 * Microsoft ActiveX SDK, version 1.0

-

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  tag under the DATA attribute:

   