PRB: MFC ActiveX Control BLOB Props Missing While Printing in Internet Explorer

ID: Q200932


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5
  • 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, 5.0sp1, 5.0sp2, 5.0sp3, 6.0


SYMPTOMS

When printing a Web page containing an MFC ActiveX control that persists one or more BLOB properties using PX_Blob, those properties print incorrectly.


CAUSE

Internet Explorer, version 4.0 and later, does not currently support persistence of MFC's BLOB properties.

When printing HTML content, Internet Explorer first saves a temporary copy of all control properties and then uses them to create a new instance of the control on a new hidden copy of the HTML page. This allows Internet Explorer to do background printing--the user can continue to use the browser while the hidden HTML page is printing. However, because BLOB properties are not persisted, the new ActiveX control instance loses any data from BLOB properties that was present before the page was printed.


RESOLUTION

The only known workaround is to convert essential properties away from the BLOB data type, possibly to the BSTR or SAFEARRAY data types.


MORE INFORMATION

Closer inspection of the problem by debugging into the MFC implementation of PX_Blob shows that during a print, first the control is asked to save its properties and the IPersistPropertyBag::Write call in CPropbagPropExchange::ExchangeBlobProp succeeds. Then, a new instance of the control is asked to load itself from the saved properties. At that time, the IPersistPropertyBag::Read call in CPropbagPropExchange::ExchangeBlobProp fails because the BLOB property in question does not exist in the property bag. In between the saving and loading of the properties, Internet Explorer has thrown out any BLOB properties.

While so-called "BLOB" properties have been available in MFC ActiveX controls for some time, there is no true support for BLOB properties in ActiveX controls. MFC simulates the traditional idea of BLOB data by storing the pointer to "BLOB" data in the VARIANT for the property data as if it were an object's dispatch pointer. Internet Explorer, ignorant of the deception, treats these properties as objects. And because it doesn't have support for persisting dispatch properties, it throws any such properties out when saving the object data.

Safe arrays are the best alternative to MFC BLOB properties for saving raw binary data from an ActiveX control. Unfortunately, MFC does not have built-in support for persisting safe arrays.

Steps to Reproduce Behavior

This problem is easily reproduced in an MFC ActiveX control that uses PX_Blob in the control's DoPropExchange function. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
Q137333 DOC: How to Use the PX_Blob Function

Additional query words: kbDSupport

Keywords : kbActiveX kbCtrl kbCtrlCreate kbDHTML kbDSupport
Version : WINDOWS:4.0,4.01,4.01 SP1,4.01 SP2,5; winnt:4.0,4.0a,4.1,4.2,4.2b,5.0,5.0sp1,5.0sp2,5.0sp3,6.0
Platform : WINDOWS winnt
Issue type : kbprb


Last Reviewed: December 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.