Browse DevX
Sign up for e-mail newsletters from DevX


Designing Complex Interfaces in VB : Page 3

Enhance your SDI interfaces using MDI techniques to build scrolling forms with menus that merge automatically depending on which form is visible.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Static Child Forms
The next sample project required designing an interface for a typical business application that consists of several modules for manipulating customers, suppliers, products, orders, and so forth. Each component of the application requires a different form. You could easily implement an MDI interface for such an application; but too many open windows on a parent MDI Form can easily confuse users, especially if a menu command opens a new window rather than activating a corresponding existing window.

Figure 3. Fixed Size: This parent form displays a different child form, depending on the command selected from the Windows menu. The current child form is centered in the available space and can't be moved or resized. The parent form can't be resized either.

In this example, users work with one window at a time and don't need to have multiple windows open at the same time. Therefore, instead of opening new child forms and letting users rearrange them on the parent form—as in a typical MDI application—you can display static child forms: forms of fixed size that can't be moved around, or be minimized/maximized, such as the one shown in Figure 3.

Users reach other basic components of the application through appropriate menu items, each of which opens the appropriate child form. The result is a very functional SDI interface. You achieve the effect of an MDI application, but user deal with only one form at a time, depending on the current operation.

The FixedChildForms sample project, shown in Figure 3, consists of a parent MDI form and a number of child forms. Users can switch between child forms by selecting the appropriate command in the Windows menu. Each child form has its own menu, which contains commands that are specific to the form and are displayed to the right of the Windows menu on the parent form's menu bar.

The application displays each child form using a set of statements such as the following, which center the child form on the parent form.

Private Sub mnuWindow1_Click() Form1.Width = ParentForm.ScaleWidth - _ 20 * Screen.TwipsPerPixelX Form1.Height = ParentForm.ScaleHeight - _ 20 * Screen.TwipsPerPixelY Form1.Left = 10 * Screen.TwipsPerPixelX Form1.Top = 10 * Screen.TwipsPerPixelX Form1.Show Form1.Label1.Width = Form1.ScaleWidth Form1.Label2.Width = Form1.ScaleWidth Form1.Label1.Caption = "Window 1" HideMenus mnuForm1.Visible = True End Sub

The child forms have no minimize/maximize buttons on their title bar and each form's Movable property is set to False. In addition, their BorderStyle property is set to 1 (Fixed Single), so that they cant be resized either. As a result, they remain fixed on the parent form. Of course, you must make sure that the controls on each child form fit in the available space.

Each child form has its own menu, but when you display a child, VB merges its menu with the parent forms menu. That happens automatically when you set the child form's NegotiateMenus property to True. To demonstrate the functionality of this style of interface I've added a simple menu to each child form. The commands of the menus don't do much: They print the name of the selected command on a Label control on the current form. The code that enables each child form to interact with the user is contained within the corresponding form.

Thanks for your registration, follow us on our social networks to keep up-to-date