共用方式為


COleControl::IsConvertingVBX

Allows specialized loading of an OLE control.

BOOL IsConvertingVBX( );

Return Value

Nonzero if the control is being converted; otherwise 0.

Remarks

When converting a form that uses VBX controls to one that uses OLE controls, special loading code for the OLE controls may be required. For example, if you are loading an instance of your OLE control, you might have a call to PX_Font in your DoPropExchange:

PX_Font(pPX, _T("Font"), *m_pMyFont, &DefaultFont);

However, VBX controls did not have a Font object; each font property was saved individually. In this case, you would use IsConvertingVBX to distinguish between these two cases:

if (!IsConvertingVBX())
{
   PX_Font(pPX, _T("Font"), *m_pMyFont, &DefaultFont);
}
else
{
   PX_String(pPX, _T("FontName"), tempString, DefaultName);
   m_pMyFont->m_pFont->put_Name(tempString.AllocSysString());
   PX_Bool(pPX, _T("FontUnderline"), tempBool, DefaultValue);
   m_pMyFont->m_pFont->put_Underline(tempBool);
}

Another case would be if your VBX control saved proprietary binary data (in its VBM_SAVEPROPERTY message handler), and your OLE control saves its binary data in a different format. If you want your OLE control to be backward-compatible with the VBX control, you could read both the old and new formats using the IsConvertingVBX function by distinguishing whether the VBX control or the OLE control was being loaded.

In your control's DoPropExchange function, you can check for this condition and if true, execute load code specific to this conversion (such as the previous examples). If the control is not being converted, you can execute normal load code. This ability is only applicable to controls being converted from VBX counterparts.

Requirements

Header: afxctl.h

See Also

Concepts

COleControl Class

COleControl Members

Hierarchy Chart

COleControl::DoPropExchange