MDI windows Singledocumentinterface SDI l Multipledocumentinterface windows MDI

  • Slides: 6
Download presentation
MDI windows Single-document-interface (SDI) l Multiple-document-interface windows (MDI) ¡ Enable users to edit multiple

MDI windows Single-document-interface (SDI) l Multiple-document-interface windows (MDI) ¡ Enable users to edit multiple documents at once ¡ The application window of an MDI program is called the parent window ¡ Each window inside the application is referred to as child window ¡ MDI can have many child windows ¡ Each child window can only has one parent ¡ Child window cannot be parent themselves ¡ A maximum of one child can be active at once ¡ Child window cannot be moved outside their parent l

To create an MDI form Create a new form l Set its Is. MDIContainer

To create an MDI form Create a new form l Set its Is. MDIContainer property to true( when you do that, the form changes appearance) l Create a child form class to be added to the form l ¡ ¡ Right-click the project in the Solution Explore Select Add Window Form. And name the file

Add child form to the parent l Must create a new child object, set

Add child form to the parent l Must create a new child object, set its Mdi. Parent property to the parent form and call method Show. Child. Form. Class *frm. Child = new Child. Form. Class(); frm. Child->Mdi. Parent = this; frm. Child->Show(); l l l Where Child. Form. Class is the name of the child frm. Child is an object name this pointer always point the current object, in this case, the parent form The code to create child usually appears in an event handler, which creates a new window in response to a user action. Menu selections (such as File followed by a submenu option New ) are commonly used to create new child windows

MDI form events and properties l Common MDI child properties ¡ ¡ l Is.

MDI form events and properties l Common MDI child properties ¡ ¡ l Is. Mdi. Child – indicates whether the form is an MDI child Mdiparent – specifies the MDI parent form of the child Common MDI parent properties ¡ ¡ Active. Mdi. Child – returns the form that is currently active MDI child(return null reference if no children are active) Is. Mdi. Container – indicates whether a form can be an MDI. Default is false.

Common Method and Event l Common method ¡ l Layout. Mdi – determines the

Common Method and Event l Common method ¡ l Layout. Mdi – determines the display of child forms on an MDI parent. Takes as a parameter an Mdilayout enumeration with possible values Arrange. Icons, Cascade, Tile. Horizontal and Tile. Vertical Common Event ¡ Mdi. Child. Activate – generated when an MDI child is closed or activated

Parent and child window Child windows can be minimized, maximized and closed independently of

Parent and child window Child windows can be minimized, maximized and closed independently of each other and of the parent window l When the parent is minimized or closed, the child windows are minimized or closed as well. l When a child window is minimized or maximized, its title bar displays a restore icon, which returns the child window to its previous size (its size before it was minimized or maximized) l