Making the Note Property Persistent

To manage the persistence of the Note property and to initialize it to a default value when the Circle control is created, add a call to a PX_ function in DoPropExchange in CIRCCTL.CPP.

Add the following line to CIRCCTL.CPP:

    PX_String(pPX, _T("Note"), m_note, _T(""));

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);
    PX_Short(pPX, _T("CircleOffset"), m_circleOffset, 0);
    PX_Long(pPX, _T("FlashColor"), (long &)m_flashColor, RGB(0xFF, 0x00, 0x00));
    PX_String(pPX, _T("Note"), m_note, _T(""));
}

Since the Note property is of type BSTR, the PX_String function is used. The m_note member variable (which holds the Note property value) and a zero-length string (which is the default value for the Note property) are parameters to this function. As with all literal strings, the property name string and default value string are passed through the _T macro before being passed as parameters to the PX_String function.