|
|
От: |
algol
|
about:blank |
| Дата: | 08.02.05 12:42 | ||
| Оценка: | |||
A>BEGIN_PROP_MAP(CMyCtrl)
A> PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
A> PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
A> PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
A> PROP_ENTRY("BorderColor", DISPID_BORDERCOLOR, CLSID_StockColorPage)
A> PROP_ENTRY("ForeColor", DISPID_FORECOLOR, CLSID_StockColorPage)
A> PROP_ENTRY("BorderVisible", DISPID_BORDERVISIBLE, CLSID_NULL)
A> PROP_ENTRY("BorderWidth", DISPID_BORDERWIDTH, CLSID_NULL)
A>END_PROP_MAP()
A>SYMPTOMS
Microsoft Word does not appear to save the properties of an Active Template Library (ATL) ActiveX control when the document is saved and then re-opened. Trace statements in ATL show that IPersistStorage and IPersistStreamInit are being called to both save and load the control's settings, but the control appears to be initialized to a new state every time the document is opened.
CAUSE
The problem occurs because ATL's implementation of IPersistStreamInit::Save and IPersistStreamInit::Load performs a QueryInterface call to get the IDispatch of the root control from which it will persist stock properties. Because Word wraps all embedded controls in an aggregated extender object, the QueryInterface call is returning the IDispatch of the Word extender and not the internal control. This causes the persist methods to fail when saving and loading the control in certain circumstances.
RESOLUTION
To resolve the problem, you need to overwrite the IPersistStreamInit_Load and IPersistStreamInit_Save functions for your control, and create modified versions of the global functions AtlIPersistStreamInit_Load and AtlIPersistStreamInit_Save. See the sample below for the steps to needed to resolve the issue.