HRESULT OnDraw(ATL_DRAWINFO& di)
{
RECT& rc = *(RECT*)di.prcBounds;
Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
char buf[80];
wsprintf(buf, "Val=%d (0x%x)", m_Value.lVal, m_Value.lVal);
TextOut(di.hdcDraw, (rc.left+rc.right)/2, (rc.top+rc.bottom)/2,
buf, lstrlen(buf));
return S_OK;
}
// Support Saving & Loading of your property...
STDMETHOD(Save)(LPSTREAM pStm, BOOL fClearDirty)
{
if(pStm) {
DWORD dwWrite;
pStm->Write(&m_Value.lVal, sizeof(long), &dwWrite);
pStm->Write(&m_sizeExtent.cx, sizeof(long), &dwWrite);
pStm->Write(&m_sizeExtent.cy, sizeof(long), &dwWrite);
SetDirty(FALSE);
}
return S_OK;
}
STDMETHOD(Load)(LPSTREAM pStm)
{
if(pStm) {
DWORD dwRead;
pStm->Read(&m_Value.lVal, sizeof(long), &dwRead);
pStm->Read(&m_sizeExtent.cx, sizeof(long), &dwRead);
pStm->Read(&m_sizeExtent.cy, sizeof(long), &dwRead);
}
return S_OK;
}