深入浅出MFC“文档/视图”架构(2)――文档模板
2009-02-11 20:00:37 来源:WEB开发网1.文档模板管理者类CDocManager
在“文档/视图”架构的MFC程序中,提供了文档模板管理者类CDocManager,由它管理应用程序所包含的文档模板。我们先看看这个类的声明:
/////////////////////////////////////////////////////////////////////////////
// CDocTemplate manager object
class CDocManager : public CObject
{
DECLARE_DYNAMIC(CDocManager)
public:
// Constructor
CDocManager();
//Document functions
virtual void AddDocTemplate(CDocTemplate* pTemplate);
virtual POSITION GetFirstDocTemplatePosition() const;
virtual CDocTemplate* GetNextDocTemplate(POSITION& pos) const;
virtual void RegisterShellFileTypes(BOOL bCompat);
void UnregisterShellFileTypes();
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); // open named file
virtual BOOL SaveAllModified(); // save before exit
virtual void CloseAllDocuments(BOOL bEndSession); // close documents before exiting
virtual int GetOpenDocumentCount();
// helper for standard commdlg dialogs
virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
//Commands
// Advanced: process async DDE request
virtual BOOL OnDDECommand(LPTSTR lpszCommand);
virtual void OnFileNew();
virtual void OnFileOpen();
// Implementation
protected:
CPtrList m_templateList;
int GetDocumentCount(); // helper to count number of total documents
public:
static CPtrList* pStaticList; // for static CDocTemplate objects
static BOOL bStaticInit; // TRUE during static initialization
static CDocManager* pStaticDocManager; // for static CDocTemplate objects
public:
virtual ~CDocManager();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
更多精彩
赞助商链接