Relationship and message transmission rules between document view frame windows

zhaozj2021-02-16  50

3.1 Documentation and Message Transfer Law between Document View Frame Window

In the MFC, M $ introduces the concept of document-viewing structure, the document is equivalent to the data container, and the window that views the data is displayed or the window interacts with the data. (This structure is in the MFC OLE, and the ODBC development is more expanded) so a complete application is generally consisting of four classes: CWINAPP application classes, CFrameWnd window frame classes, cDocument document classes, CView view class. (Supported in VC6 without document - Applications) Cover CWINAPP in the program runtime CWINAPP will create a CFRAMEWND FLEW window, and the Frame Window will create a document template, then have a document template to create a document instance and view instance, and associate with both . Generally speaking, we only need to operate documents and visual operations, and the various behaviors of the framework have been arranged by MFC without human intervention. This is also the intention of M $ design document - the spiritual structure, let us pay attention to finish The task is discharged from the interface writing. One document is applied to the application, but a document can contain multiple views. Only one frame window is used in an application, and there may be multiple MDI sub-windows for multi-document interfaces. Each look is a sub-window, the parent window in a single document interface is a frame window, in the multi-document interface, the parent window is the MDI sub-window. A multi-document application can contain multiple document templates, one template defines a correspondence between a document and one or more views. The same document can belong to multiple templates, but only one document is allowed in a template. The same approach can also belong to multiple document templates. (I don't know if I said it is clear) Next, look at how to get a pointer to various objects in the program:

Global Functions AFXGetApp You can get the CWINAPP application class pointer AFXGetApp () -> m_pmainwnd is in the Frame window pointer in the frame window: cfraMew :: getActiveDocument Get the current activity document pointer in the frame window: cframeWnd :: getActiveView gets the current activity Picture pointer in the view : CView :: getDocument Get the corresponding document pointer in the document: cdocument :: getFirstViewPosition, cdocument :: getNextView is used to traverse all and document associations. In the document: cdocument :: getDoCtemplate Get the Document Template Pointer in the Multi-Document Interface: cmdiframeWnd :: MDiGetAn Gets the current active MDI sub-window Generally speaking users enter messages (such as menus selection, mouse, keyboard, etc.) If it is not processed, it will be sent to the Framework window. So defining a message mapping is defined in the view, if an application has multiple views while the current activity does not process the message, the message will be sent to the frame window.

转载请注明原文地址:https://www.9cbs.com/read-23058.html

New Post(0)