Multi-document interface window

Source: Internet
Author: User

MDIApplicationProgramIs another important type of document view program. It features that users can open multiple documents at a time, and each document corresponds to a different window; the menu of the main window will automatically change with the change of the subwindow of the current activity; sub-windows can be stacked, tiled, and other operations; Sub-windows can beMDIPosition, change, maximize, and minimize the size of the main window. When the sub-window is maximized, it will be full.MDIAll customer zones in the main window.MDIYou can not only open multiple documents at the same time, but also open multiple views for the same document. InWindowsSelectNewTo open a new subwindow for the current activity document.

From the programmer's perspectiveMDIThe application must haveCmdwndOr an instance of its derived class. This window is calledMDIFramework Window.CmdwndYesCframewndIn additionCframewndIn addition to all the features of the Framework window classMDIRelated features:

Unlike SDI, the main framework window is not directly associated with a document and view. The MDI frame window has mdiclient (MDI client window). When displaying or hiding a control bar (including a toolbar, status bar, or dialog bar), you can reposition the Child Window.

The MDI customer window is the direct parent window of the MDI child window. It manages the customer area of the main frame window and creates a child window. Each MDI main frame window has only one MDI customer window.

MDISub-window isCmdichildwndOr its derived class instance,CmdichildwndYesCframewndIs used to hold views and documents. It is equivalentSDIMain Frame window. Each time a document is opened, the Framework automatically createsMDISubwindow. OneMDIThe application is responsible for dynamic creation and deletion.MDISubwindow. At any time, only one subwindow is active.(The color of the window title bar is highlighted.).MDIThe Framework Window is always associated with the current active subwindow, and the command message is being sentMDIThe Framework Window is first assigned to the current activity subwindow.

In the absence of any activityMDIIn the subwindow,MDIThe Framework Window can have its own default menu. When there is an activity subwindow,MDIThe menu bar of the frame window is replaced by the menu bar of the quilt window. The framework automatically monitors the subwindow type of the current activity and changes the menu of the Main Window accordingly. For exampleVisual StudioWhen you select the resource editing window or source program window in the dialog box, the menu varies. However, for programmersInitinstanceWhen registering a document, specify the menus used by each type of sub-window (strictly speaking, the document) without explicitly changing the menu of the main frame window by calling the function, because the framework will automatically complete this task.

MDI frame windows provide default menu responses for some standard window operations, such as cascade, tile, arrange subwindows, and create new subwindows. In response to the new subwindow command, the Framework calls cdoctemplate: createnewframe () to create a subwindow for the current activity document. createnewframe () not only creates subwindows, but also views corresponding to documents.

Void cmainframe: onsecondmdi () // display the second subwindow {// todo: add your command handler code herecmultidoctemplate * pdoctemplate; pdoctemplate = (cmultimdiapp *) afxgetapp ()) -> pdoctemplate2; // onnewview (pdoctemplate); // method pdoctemplate-> opendocumentfile (null); // if the method in method 2 is null, a new document is created. This document type is associated with this template. // if you want to open only one window, click it to activate the previously opened window, two Methods: // The first method of document traversal // The second method of variable setting. In the cchildframe constructor, the variable is 1, and the Destructor minus 1} bool cmainframe :: onnewview (cmultidoctemplate * pdoctemplate) {javasichildwnd * pactivechild = mdigetactive (); cdocument * pdocument; If (pactivechild = NULL | (pdocument = pactivechild-> getactivedocument ()) = NULL) {assert (pdoctemplate! = NULL); Assert (pdoctemplate-> iskindof (runtime_class (cdoctemplate); pdoctemplate-> opendocumentfile (null); Return true;} assert_valid (pdoctemplate ); // create a framework window cframewnd * pframe = pdoctemplate-> createnewframe (pdocument, pactivechild) that contains documents and views; // the document referenced in the new framework window with the preceding parameters, the optional null value // The following parameter. Provides the mode based on the new frame window if (pframe = NULL) {trace0 ("Warning: failed to create new frame \ n"); Return false ;} pdoctemplate-> initialupdateframe (pframe, pdocument); // enable views in the Framework Window to receive their oninitialupdate calls return true ;}

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.