<kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

              <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                      <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                              <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                      <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                              <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                                      <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                                              <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                                                      <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                                                              <kbd id='8zV6tv7kItLsnlJ'></kbd><address id='8zV6tv7kItLsnlJ'><style id='8zV6tv7kItLsnlJ'></style></address><button id='8zV6tv7kItLsnlJ'></button>

                                                                                        您好,欢迎访问深圳市精科创电子设备有限公司官方网站!凯发娱乐注册  凯发娱乐注册官网  凯发娱乐注册网址更多
                                                                                  新闻资讯NEWS 聚焦行业热点
                                                                                  凯发娱乐注册_深入浅出MFC文档/视图架构之文档模板
                                                                                  时间:2018-01-06 07:01  点击率:  作者:凯发娱乐注册   来源:凯发娱乐注册官网

                                                                                    文档模板打点者类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
                                                                                  };


                                                                                    从上述代码可以看出,CDocManager类维护一个CPtrList范例的链表m_templateList(即文档模板链表,现实上,MFC的计划者在MFC的实现中大量行使了链表这种数据布局),CPtrList范例界说为:

                                                                                  class CPtrList : public CObject
                                                                                  {
                                                                                   DECLARE_DYNAMIC(CPtrList)

                                                                                   protected:
                                                                                    struct CNode
                                                                                    {
                                                                                     CNode* pNext;
                                                                                     CNode* pPrev;
                                                                                     void* data;
                                                                                    };
                                                                                   public:

                                                                                    // Construction
                                                                                    CPtrList(int nBlockSize = 10);

                                                                                    // Attributes (head and tail)
                                                                                    // count of elements
                                                                                    int GetCount() const;
                                                                                    BOOL IsEmpty() const;

                                                                                    // peek at head or tail
                                                                                    void*& GetHead();
                                                                                    void* GetHead() const;
                                                                                    void*& GetTail();
                                                                                    void* GetTail() const;

                                                                                    // Operations
                                                                                    // get head or tail (and remove it) - don't call on empty list!
                                                                                    void* RemoveHead();
                                                                                    void* RemoveTail();

                                                                                    // add before head or after tail
                                                                                    POSITION AddHead(void* newElement);
                                                                                    POSITION AddTail(void* newElement);

                                                                                    // add another list of elements before head or after tail
                                                                                    void AddHead(CPtrList* pNewList);
                                                                                    void AddTail(CPtrList* pNewList);

                                                                                    // remove all elements
                                                                                    void RemoveAll();

                                                                                    // iteration
                                                                                    POSITION GetHeadPosition() const;
                                                                                    POSITION GetTailPosition() const;
                                                                                    void*& GetNext(POSITION& rPosition); // return *Position++
                                                                                    void* GetNext(POSITION& rPosition) const; // return *Position++
                                                                                    void*& GetPrev(POSITION& rPosition); // return *Position--
                                                                                    void* GetPrev(POSITION& rPosition) const; // return *Position--

                                                                                    // getting/modifying an element at a given position
                                                                                    void*& GetAt(POSITION position);
                                                                                    void* GetAt(POSITION position) const;
                                                                                    void SetAt(POSITION pos, void* newElement);

                                                                                    void RemoveAt(POSITION position);

                                                                                    // inserting before or after a given position
                                                                                    POSITION InsertBefore(POSITION position, void* newElement);
                                                                                    POSITION InsertAfter(POSITION position, void* newElement);

                                                                                    // helper functions (note: O(n) speed)
                                                                                    POSITION Find(void* searchValue, POSITION startAfter = NULL) const;
                                                                                    // defaults to starting at the HEAD
                                                                                    // return NULL if not found
                                                                                    POSITION FindIndex(int nIndex) const;
                                                                                    // get the 'nIndex'th element (may return NULL)

                                                                                    // Implementation
                                                                                   protected:
                                                                                    CNode* m_pNodeHead;
                                                                                    CNode* m_pNodeTail;
                                                                                    int m_nCount;
                                                                                    CNode* m_pNodeFree;
                                                                                    struct CPlex* m_pBlocks;
                                                                                    int m_nBlockSize;

                                                                                    CNode* NewNode(CNode*, CNode*);
                                                                                    void FreeNode(CNode*);

                                                                                   public:
                                                                                    ~CPtrList();
                                                                                    #ifdef _DEBUG
                                                                                     void Dump(CDumpContext&) const;
                                                                                     void AssertValid() const;
                                                                                    #endif
                                                                                    // local typedefs for class templates
                                                                                    typedef void* BASE_TYPE;
                                                                                    typedef void* BASE_ARG_TYPE;
                                                                                  };
                                                                                  很显然,CPtrList是对链表布局体
                                                                                  struct CNode
                                                                                  {
                                                                                   CNode* pNext;
                                                                                   CNode* pPrev;
                                                                                   void* data;
                                                                                  };


                                                                                    自己及其GetNext、GetPrev、GetAt、SetAt、RemoveAt、InsertBefore、InsertAfter、Find、FindIndex等各类操纵的封装。

                                                                                    作为一个抽象的链表范例,CPtrList并未界说个中节点的详细范例,而以一个void指针(struct CNode 中的void* data)奇妙地实现了链表节点成员详细范例的"模板"化。很显然,在Visual C++6.0开拓的年月,C++说话所具有的语法特性"模板"如故没有获得普及的应用。
                                                                                  而CDocManager类的成员函数

                                                                                  上一篇:写好企业消息稿问题的5个能力 下一篇:培生大中华区人事调解后最新架构(图示)