// ex32aDoc.cpp : implementation of the CEx32aDoc class // #include "stdafx.h" #include "ex32a.h" #include "ex32aDoc.h" #include "SrvrItem.h" #include "TextDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc IMPLEMENT_DYNCREATE(CEx32aDoc, COleServerDoc) BEGIN_MESSAGE_MAP(CEx32aDoc, COleServerDoc) //{{AFX_MSG_MAP(CEx32aDoc) ON_COMMAND(ID_MODIFY, OnModify) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc construction/destruction CEx32aDoc::CEx32aDoc() { // Use OLE compound files EnableCompoundFile(); // TODO: add one-time construction code here } CEx32aDoc::~CEx32aDoc() { } BOOL CEx32aDoc::OnNewDocument() { m_strText = "Initial default text"; if (!COleServerDoc::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc server implementation COleServerItem* CEx32aDoc::OnGetEmbeddedItem() { // OnGetEmbeddedItem is called by the framework to get the COleServerItem // that is associated with the document. It is only called when necessary. CEx32aSrvrItem* pItem = new CEx32aSrvrItem(this); ASSERT_VALID(pItem); return pItem; } ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc serialization void CEx32aDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { ar << m_strText; } else { ar >> m_strText; } } ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc diagnostics #ifdef _DEBUG void CEx32aDoc::AssertValid() const { COleServerDoc::AssertValid(); } void CEx32aDoc::Dump(CDumpContext& dc) const { COleServerDoc::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CEx32aDoc commands void CEx32aDoc::OnModify() { // TODO: Add your command handler code here CTextDialog dlg; dlg.m_strText = m_strText; if (dlg.DoModal() == IDOK) { m_strText = dlg.m_strText; UpdateAllViews(NULL); // Trigger CEx32aView::OnDraw UpdateAllItems(NULL); // Trigger CEx32aSrvrItem::OnDraw SetModifiedFlag(); } }