Because the Circle control uses the CircleShape property as a key to determine how to draw itself, it is important to initialize the CircleShape property to a specific value. Modify the CCircCtrl::DoPropExchange
function. To do this, add the following line to CIRCCTL.CPP:
PX_Bool(pPX, _T("CircleShape"), m_circleShape, TRUE);
as shown in the following code example:
void CCircCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
PX_Bool(pPX, _T("CircleShape"), m_circleShape, TRUE);
}
As stated earlier in CircleShape Property Functionality, the initialized state of CircleShape must be TRUE if you want the control initially drawn as a perfect circle. This is accomplished by adding a call to the PX_Bool function in the DoPropExchange
function, which sets the default value of the CircleShape property to TRUE.
First, the property name string parameter to the PX_Bool function is passed through the _T macro. This macro is used for compatibility among different string representations. For instance, UNICODE strings are available for 32-bit ActiveX controls. All literal strings in an ActiveX control project must be handled in this manner.
Any property initialized with a call to a PX_ function in the DoPropExchange
function is called a “persistent property” because the PX_ functions do more than initialize a property when a control is created. The DoPropExchange
function is called when a control is created, restored from a file or stream, or saved to a file or stream. The PX_ functions determine whether the value of a persistent property must change under any of these conditions. Whenever a persistent property is changed, a modified flag for persistent properties must be set to indicate that at least one persistent property must be updated. Setting the modified flag is discussed later in this lesson, in Modifying OnCircleShapeChanged.