Wednesday, December 12, 2012

MDI form in visual basic


The Multiple Document Interface (MDI) was designed to simplify the exchange of information among documents, all under the same roof. With an MDI application, you can maintain multiple open windows, but not multiple copies of the application. Data exchange is easier when you can view and compare many documents simultaneously. You almost certainly use Windows applications that can open multiple documents at the same time and allow the user to switch among them with a mouse-click. Microsoft Word is a typical example.

An MDI application must have at least two Forms, the parent Form and one or more child Forms. Each of these Forms has certain properties. There can be many child Forms contained within the parent Form, but there can be only one parent Form.
To create an MDI application, follow these steps:
1.  Start a new project and then choose Project ®Add MDI Form to add the parent Form.
2.  Set the Form’s caption to MDI Window.
3.  Choose Project Ø Add Form to add a regular Form.
4.  Make this Form the child Form by setting its MDIChild property to True. To denote that this is a child Form, set its Caption property to MDI Child Form.
The Arrange Property
Windows offers three ways of arranging the windows on an MDI Form. You can cascade them, tile them vertically, or tile them horizontally. Of course, the user can resize and move the windows around, but the automatic placement comes in handy when the MDI Form becomes messy and the user can no longer easily locate the desired window.
Constant
Value
Description


vbCascade
0
Cascades all child Forms
vbTileHorizontal
1
Tiles all child Forms horizontally
vbTileVertical
2
Tiles all child Forms vertically
vbArrangeIcons
3
Arranges the icons for minimized child Forms at the bottom of the MDI Form



Difference between mdi and sdi

1.      MDI = "Multiple Document Interface"
SDI = "Single Document Interface"
2.      MDI is when your application consists of an MDI parent-form
that contains all the other window/forms that the app consists of.
SDI is stand-alone, ordinary windows/forms that exist independently
of each other.
3.      MDI is multiple document interfaces and is essentially a way of creating a shell holder for lots of different windows. (in a way like a browser with tab support, it loads the browser once and then has all the windows within it)
SDI is single document interface and loads as the full program with no internal window support. Kind like a browser with no tab support so a new page has to be opened in a new version of the browser.

Advantages of SDI

·         An SDI interface works very well with multiple monitors and multiple virtual desktops. It also allows users to switch between multiple open documents using the native Windows taskbar and task manager, rather than through special code that must be written into your application.

Advantages of MDI

MDI applications can often handle multiple documents more readily than SDI programs. For example, many MDI text editors allow the user to open multiple text files side by side in the same window, making it easy to compare and look up information from a second document while working on the first.

Go to visual Basic theory index