Article ID: 152000
Article Last Modified on 11/21/2006
// these get and set functions are the same as the original with a minor
// change (noted in the code)
short CTestAppearanceCtrl::GetAppearance()
{
return m_MyAppearance;
}
void CTestAppearanceCtrl::SetAppearance(short nNewValue)
{
if (nNewValue != 0 && nNewValue != 1)
ThrowError(CTL_E_INVALIDPROPERTYVALUE,
AFX_IDP_E_INVALIDPROPERTYVALUE);
// Is the property changing?
if (m_MyAppearance == nNewValue)
return;
if (!BoundPropertyRequestEdit(DISPID_APPEARANCE))
SetNotPermitted();
// changed from original
// do not use the WS_EX_CLIENTEDGE style
//ASSERT((m_hWnd == NULL) ||
// ((GetExStyle() & WS_EX_CLIENTEDGE) == (DWORD)(m_sAppearance ?
// WS_EX_CLIENTEDGE : 0)));
m_MyAppearance = nNewValue;
SetModifiedFlag();
//ToggleAppearance(this);
// end of changes
OnAppearanceChanged();
BoundPropertyChanged(DISPID_APPEARANCE);
}
void CTestAppearanceCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
pdc->FillRect(rcBounds,
CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
pdc->Ellipse(rcBounds);
// draw as 3D if m_appearance is set
if(m_appearance)
{
CRect rect(rcBounds);
pdc->DrawEdge(rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
}
}
Additional query words: 4.00 4.10 DISPID_APPEARANCE
Keywords: kbctrlcreate kbprb kbuidesign KB152000