HOWTO: Saving a Blob Property in ActiveX Control Pad

Last reviewed: July 2, 1997
Article ID: Q167827
The information in this article applies to:
  • The Microsoft Foundation Classes (MFC) included 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 <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:

   ARTICLE-ID: Q137333
   TITLE     : DOC: How To Use the PX_Blob Function
 

	
	


Keywords : AXSDKControls kbprg MfcOLE
Technology : kbMfc kbole
Version : 1.0 4.0 4.0a 4.1 4.2 4.2b 5.0
Platform : NT WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.