The CircleOffset functional specification requires that the value of the CircleOffset property be reset to 0 when CircleShape is set to TRUE. Recall from the previous lesson, Adding a Custom Notification Property, that the OnCircleShapeChanged
function is called whenever the CircleShape property is modified, so it is the appropriate place to handle this requirement. Modify OnCircleShapeChanged
by adding the lines of code beginning with:
//reset the circle offset, if necessary:
as shown in the following example:
void CCircCtrl::OnCircleShapeChanged()
{
// force the control to redraw itself
InvalidateControl();
SetModifiedFlag();
// reset the circle offset, if necessary
if (m_circleShape)
SetCircleOffset(0);
}
Setting the CircleOffset property to 0 under this condition causes the circle to be centered whenever the CircleShape property is set back to TRUE. All actions related to the CircleShape property change are completed before the CircleOffset property is changed.