An Application of Multiple Forms |
|
Using Multiple Forms |
When you create a Windows Application, it starting form is made available to you. If one form is not enough for your application, you can add as many as necessary. To add (or to create) a (new) form, you should display the Add New Item dialog box. To do this,
On the Add New Item dialog box, in the Templates section, click Window Form (.NET), provide a name in the Name edit box and click Open. If your application is using various forms and you want to display a particular one at design time, on the main menu, you can click Window. On the list of files,
If you visually add two (or more) forms to your application, you may need to link them, allow one to call the other. Since each form is created in its own header file, to let one form know about the existence of another, you must include its header. A form or unit that wants to communicate with another is called a client of the form. |
|
The Multiple Document Interface (MDI) |
Introduction to MDI-Based Applications |
A multiple document interface, abbreviated MDI, is an application whose main form directly "owns" other forms. The main form is also considered the parent. The forms that the parent form owns can display only within the rectangular borders of the parent form. The main idea behind an MDI is to allow the user to open different documents and work on them without having to launch another instance of the application. As opposed to an MDI, a Single Document Interface (SDI) allow only one document at a time in the application. WordPad is an example of an SDI. The user can open only one document at a time. If he wants another WordPad document, he must open an additional instance of WordPad. Each form that is child of the main form in an MDI can be a fully functional form and most, if not all, child forms are of the same kind. There are two main ways a child document of an MDI displays. To provide information about its state, a child form is equipped with a title bar. The title bar of a child form displays an icon, the name of its document, and its own system buttons. Since it can be confined only within the parent form, it can be minimized, maximized, or restored within the parent form. When a child form is not maximized, it clearly displays within the parent form. If it gets closed and there is no other child form, the parent form would appear empty. If there are various child forms, they share the size of the client area of the parent form. If one of the child forms is maximized, it occupies the whole client area of the main form and it displays its name on the title bar of the main form. |
MDI Creation |
It is not particular difficult to create an MDI application. The challenge may come when you need to configure its functionality. To start, you must set a form to be the eventual parent of the application. This can be taken care of by setting its IsMDIContainer property to true. After doing this, the body of the form is painted in gray with a sunken client area that indicates that it can host other form. After creating the parent form of the MDI, you must provide a way to display a child form when needed. This is usually done with a menu, which we haven't covered yet. When displaying a child form of the MDI, access its MdiParent property and assign it the name of the parent form. Then display the child. |
|
|
||
Previous | Copyright © 2003-2015, FunctionX | Next |
|