Setting the CircleOffset Default Value

Similar to other properties, the CircleOffset property must be initialized to a default value when the control is created. In this case, setting CircleOffset to 0 is logical. Add the following line:

    PX_Short(pPX, _T("CircleOffset"), m_circleOffset, 0);

to the DoPropExchange function in CIRCCTL.CPP:

void CCircCtrl::DoPropExchange(CPropExchange* pPX)
{
    ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
    COleControl::DoPropExchange(pPX);

    PX_Bool(pPX, _T("CircleShape"), m_circleShape, TRUE);
    PX_Short(pPX, _T("CircleOffset"), m_circleOffset, 0);
}

The CircleOffset property is initialized by calling PX_Short in the CCircCtrl::DoPropExchange member function, passing 0 as the default value parameter (the last parameter in the function call). Now, when the circle is first drawn, it will be centered in the bounding rectangle of the Circle control. As with all literal strings, the property name parameter must be passed through the _T macro.

Properties initialized by calling a PX_ function in a control's DoPropExchange function are persistent properties; thus, CircleOffset is a persistent property. Steps described in Setting the Circle Offset Property will set the modified flag for persistent properties whenever the value of the CircleOffset property changes.