Declaring the COleServerItem Class
Your application should contain a server item class derived from
COleServerItem. It is important to override
OnGetExtent(),
OnDraw(), and
Serialize(). The declaration of your
COleServerItem derived class should look like
Example 21.
Example 21 – Declaration of a COleServerItem derived class
class CMyAppSrvrItem : public COleServerItem
{
VIEWS_DECLARE_DYNAMIC(CMyAppSrvrItem)
// Constructors
public:
CMyAppSrvrItem(CMyAppDoc* pContainerDoc);
// Attributes
CMyAppDoc* GetDocument() const
{ return (CMyAppDoc*)COleServerItem::GetDocument(); }
CMyAppViewport* GetViewport();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyAppSrvrItem)
public:
virtual BOOL OnDraw(CDC* pDC, CSize& rSize);
virtual BOOL OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize);
//}}AFX_VIRTUAL
// Implementation
public:
~CMyAppSrvrItem();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
virtual void Serialize(CArchive& ar); // overridden for document i/o
}