The relationship of class CView class of CWinApp class CMultiDocTemplate class CDocument

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/bboot/article/details/26884011

Had to turn, instantly clarified a lot of questions, dapper

1.CWinApp class

It contains and manages all the information for the application's documentation/Windows. It has a member variable Cdocmanager*m_pdocmanager, which is the manager of the Document/window; m_templatelist is a list in Cdocmanager, which holds pointers to all document templates when the user calls CWinApp :: AddDocTemplate (Pdoctemplate) after the pdoctemplate was deposited in the Cwinapp::m_pdocmanager::m_templatelist list.

The following two functions are lookup and traversal operations on M_templatelist:

Cwinapp::getfirstdoctemplateposition ()//Get the location of the position type for the first document template
Cwinapp::getnextdoctemplate (Position&pos)//Get the document template for POS location and pass the Positoon location of the next template to Pos;

2.CDocTempplate class

Commonly used its derived classes CSingleDocTemplate class and CMultiDocTemplate class

(1). CSingleDocTemplate Class (Inheritance and Cdoctempplate Class)

You can open only one document at a time and one view or more to open multiple types of documents (open one to close another document)

(2). CMultiDocTemplate Class (Inheritance and Cdoctempplate Class)

This is a very important class. Cmultidoctemplate::m_doclist holds a list of pointers to the document instances for all such documents. The following two functions are used to maintain cmultidoctemplate::m_doclist data
Cmultidoctemplate::adddocument (cdocument* pDoc);
Cmultidoctemplate::removedocument (cdocument* pDoc);
The following two functions are used to sample all document instances of the document type.
Cmultidoctemplate::getfirstdocposition () const;
Cmultidoctemplate::cdocument*getnextdoc (position&rpos) const;
3.CDocument class
CDocument Each document instance can have more than one view corresponding to it.
Cdocument::m_viewlist is used to save all view associated with this document instance
Cdocument::getdoctemplate can obtain an instance of the corresponding document template such as the CMultiDocTemplate type of document template;

4, CView class

For example, in the framework of multiple document views, each CMDIChildWnd has a view

Cview::getdocument can obtain CDocument related to this view
Cview::getparentframe () can obtain CMDIChildWnd;

The above analysis shows that Cwinapp,cmdichildwnd,cview,cdocument,cmultidoctemplate knows that one of the instances must know all the other instances, and CWinApp commands the global Any time a CWinApp instance is obtained, all document template document instances, views, frame windows can be enumerated. AfxGetApp () Gets the CWinApp instance pointer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.