Microsoft KB Archive/200932

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

Article ID: 200932

Article Last Modified on 7/22/2001

-

APPLIES TO

 Microsoft Internet Explorer 4.0 128-Bit Edition Microsoft Internet Explorer 4.01 Service Pack 2 Microsoft Internet Explorer 4.01 Service Pack 1 Microsoft Internet Explorer 4.01 Service Pack 2 Microsoft Internet Explorer 5.0 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Standard Edition</li></ul>

 Microsoft Visual C++ 6.0 Service Pack 5</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q200932

<div class="symptoms_section">

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.

<div class="cause_section">

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.

<div class="resolution_section">

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

<div class="moreinformation_section">

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

Additional query words: kbDSupport

Keywords: kbctrlcreate kbprb kbctrl kbdhtml KB200932

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.