Declaring the COleServerDoc Class
The document class in your application must derive from
COleServerDoc. It should declare at least one member variable that is derived from
CODModel. It should override the
OnGetEmbeddedItem() method for creating server items. It should also override
OnDeactivate(). The declaration of your
COleServerDoc derived class should look like
Example 20.
Example 20 – Declaration of a COleServerDoc derived class
class CMyAppDoc : public COleServerDoc
{
protected: // create from serialization only
CMyAppDoc();
VIEWS_DECLARE_DYNCREATE(CMyAppDoc)
// Attributes
public:
CMyAppSrvrItem* GetEmbeddedItem()
{ return (CMyAppSrvrItem*)COleServerDoc::GetEmbeddedItem(); }
protected:
CMyAppModel m_mdlCanvas;
public:
// Gets a pointer to the model of the diagram.
CMyAppModel* GetModel() { return &m_mdlDiagram; }
// Determines if the diagram has been modified.
virtual BOOL IsModified();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyAppDoc)
virtual void DeleteContents();
protected:
virtual COleServerItem* OnGetEmbeddedItem();
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
virtual void OnDeactivate();
//}}AFX_VIRTUAL
...
}