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



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5
  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 4.0a
    • Microsoft Visual C++, 32-bit Editions 4.1
    • Microsoft Visual C++, 32-bit Editions 4.2
    • Microsoft Visual C++, 32-bit Editions 4.2b
    • Microsoft Visual C++, 32-bit Editions 5.0
    • Microsoft Visual C++, 32-bit Editions 6.0

This article was previously published under Q200932

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:

137333 DOC: How to Use the PX_Blob Function


Modification Type:MajorLast Reviewed:7/22/2001
Keywords:kbCtrl kbCtrlCreate kbDHTML kbDSupport kbprb KB200932