When you create an MDI application, you must make sure you provide your users with the ability to create documents. In fact, probably one of your first assignments is to make sure the user can create as many documents as necessary. As the documents are created, you need a way to programmatically keep track of the child forms. For example, you can store the documents in a collection. To assist you with this, the Form class is equipped with a property named MdiChildren, which is a read-only array. Each element of the MdiChildren[] array is of type Form. Therefore, to access a child form of an MDI application, you can pass an index to this property.
Based on the standards defined in the operating system, as child forms are created in an MDI application, they are positioned each on top of the previous one but below the next one. The arrangement uses a 3-D coordiniate system whose origin is on the lower-left corner of the parent's frame just under the title bar (or the menu, if any; or the toolbar, if any), with the Z axis moving from the monitor towards you:
The operating system allows the user to choose among different arrangements. For example, you can position the documents as vertical columns, as horizontal rows, or as tiles. To support this, the Form class is equipped with a method named LayoutMdi. Its syntax is: member LayoutMdi : value:MdiLayout -> unit The LayoutMdi() method takes an argument that is a member of the MdiLayout enumeration. The members of this enumeration are Cascade, TileHorizontal, TileVertical, and ArrangeIcons.
In most MDI applications, a user can create as many documents as necessary. This also means that the application can hold many child forms. To access a child form, the user can click its title bar. You can also provide options on a menu item named Window that would display a list of open documents. When a child window is activated, it fires an event named MdiChildActivate: member MdiChildActivate : IEvent<EventHandler, EventArgs> The MdiChildActivate event is of type EventArgs. The document that is currently active has a brighter title bar. To identify this document, the form has a property named ActiveMdiChild: member ActiveMdiChild : Form with get This read-only property allows you to know what document is the current active one. This property is of type Form, which means that it produces a Form object. When you enquire about this property, if its value is null, this means that there is no current active document. If the value of the ActiveMdiChild property is not null, a document is active and you can use it.
In an MDI application, if the user doesn't want to display a document but doesn't want to close it, he can minimise the window. In the same way, the user can minimize as many child forms as necessary. When a child form has been minimized, it shows a button in the lower part of the parent. The buttons of the other minimized child forms are usually positioned next to each other:
The user can move the buttons at will:
A user can also close the child form using the Close button of its minimized button. At one time the minimized buttons may display as a "mess". To let you rearrange them, call the LayoutMdi method of the Form class and pass the argument as ArrangeIcons. When you do this, the application will visit all buttons, if any, that represent minimized child documents, and position them from the left to the right, adjacently. |