mfc--relationships between documents, views, frame windows, document templates

Source: Internet
Author: User
1, the first should have a full understanding of the CWinApp class
It contains and manages all the information for the application's documentation/Windows. It has a member variable
Cdocmanager * M_pdocmanager, this variable is the document/window manager, 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.
Cwinapp::getfirstdoctemplateposition ()
Cwinapp::getnextdoctemplate (position& POS)
is a sample of all document template pointers.

2, above we mentioned the document template (CMultiDocTemplate (we mainly for the document)),
This is a very important class. Cmultidoctemplate::m_doclist all of the documents stored in the
A list of pointers to the document instance. The following two functions are used to maintain cmultidoctemplate::m_doclist data
Cmultidoctemplate::adddocument (cdocument* pDoc);
Cmultidoctemplate::removedocument (cdocument* pDoc);
and
Cmultidoctemplate::getfirstdocposition () const;
cmultidoctemplate::cdocument* Getnextdoc (position& rpos) const;
Used to sample all document instances of this document type.

3. Documents mentioned above (CDocument)
CDocument we are most familiar with. 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 cmultidoctemplate;
4, CView He is placed in the CMDIChildWnd, each cmdichildwnd has a view
Cview::getdocument can obtain CDocument related to this view
Cview::getparentframe () can obtain CMDIChildWnd;

The above analysis shows that one instance is known between cwinapp,cmdichildwnd,cview,cdocument,cmultidoctemplate
Must know all the other instances, CWinApp commanding the global, any time, as long as the CWinApp instance, then all the document template,
The document instance, depending on the frame window, can be enumerated. AfxGetApp () Gets the CWinApp instance pointer.
Related Article

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.