Creating SDI application: – Our note pad is a based example of SDI application. It is a simple text editor. The SDI notepad application uses a SDI form. At run time, only one window will be open. In this form, user can add menu bar, standard toolbar, edit toolbar and show on the SDI form. All the menus and toolbar can be activated or use by the user at run time. This SDI form works similar to notepad application.

For designing single document interface, we need at least a menu bar just below the title bar. The menu bar which is also called a menu system. When a document interface has several operation for the user to choose from, a menu system is more commonly used than command button. A menu system is collection of commands organized in one or more dropdown menus. Visual basic menu editor allow us to create a custom menu system.

A menu system designed by using menu control. The menu system consist of several components such as menu name, menu command, shortcut key, disabled menu command, check menu command, sub menu, and separator bar.

  1. Menu name: – Each drop down menu has a name. A menu name is listed on the menu bar just below the form’s title bar. The menu names such as file, edit, view, help, etc. These menu names are activate at run time. Menu name may contains an access key such as the file menu contains letter F as an access key. At run time, we can use file menu either by clicking mouse pointer on it or by using Alt+F to activate the file menu.
  2. Menu command: – Menus have several command. The user selects a command by clicking it, entering its access key, entering its shortcut key.
  3. Shortcut key: – A shortcut key is a key or combination of key that cause a menu command to execute. Shortcut keys are shown on a menu to the right of their corresponding command. For example, CTRL+C is the shortcut key for the copy command. Here is the primary difference between a shortcut key an access key such as an access key is activated wild menus is open but a shortcut key access directly without opening a menu.
  4. Disabled menu command: – We can cause a menu command to be disabled when we do not want the user to select it. A disabled menu command appears in dim color and cannot be selected.
  5. Checked menu command: – A checked menu command is usually one that turns an option on or off. A check mark appears to the left of the command appears to the left of the command indicating the option is turned on. When no check mark appear to the left of the command, the option is turned off. The user toggles a checked menu command each time he or she select it.
  6. Sub menu: – Some of the commands on a menu are actually the names of sub menus. We can tell when a command is the name of sub menu because a right arrow appears to its right. Activating the name of a sub menu causes the sub menu to appear.
  7. Separator bar: – A separator bar is a horizontal bar used to separate group of commands. For example, cut, copy and paste are group command and are separated by a separator bar.

Menu Control: – An application menu system is constructed from menu controls. Each menu name, menu command and separator bar is a separate control. When we create menu controls, we name them with MNU prefix. We placed the text we went to displayed by a menu control is its caption properties. As with other controls, access keys are assigned by an ampersand sign in the caption properties before the character that is to because the access key. The names of the controls that are the commands of the menu. Write other controls in visual basic, menu controls have properties and respond to events. We make a menu functional by writing click event procedure for the control.

Menu editor: – We create menu control with menu editor. We start menu editor with one of the following action.

  1. Click the menu editor button from the standard toolbar. Or
  2. Click tools menu from menu bar then click on menu editor option from tools menu. Or
  3. Press CTRL+E, in all cases, a menu editor dialog box will open. This dialog box divided into two parts vertically. First part contains, caption, name, index, shortcut, help contest id, negotiate position text boxes and list boxes and it also contains four check boxes such as checked, enable, visible and window list. There are mine command button also available in this area for different operation. Second help portion of the dialog box displayed as empty. When user choose menu name, menu command, such command, etc., it appear on this area. Here are description of the field that we will used in this text.
    1. Caption: – A caption is used for menu name which is displayed in the menu list. We can assign an ampersand sign before a character in the caption. If we want the control to be a separator bar, the caption should be sets to a hyphen (-).
    2. Name: – The name text box is used to assign a name of menu, menu command, sub menu and show on. We can use only this name in visual basic program. Normally name can be prefix with MNU. Type the name of the menu control in this filled.
    3. Shortcut: – A shortcut is dropdown list box. When we click on dropdown arrow, a list of shortcut name are displayed on dialog box. Select any one shortcut key out of multiple option by clicking on it.
    4. Enabled: – This field is checked by default, which causes the menu control to initially appear enabled. Uncheck it to cause the control initially appear disabled.
    5. Checked: – This is also a check box. This check box is used to enable or disable any command control. By default initially check mark appear with this command.

Upper half of the dialog box contains to command button and button half of the dialog box has a set of button with arrows as well as buttons labeled next, insert and delete. The upper half dialog box contains two button labeled ok and cancel. The ok button used to save and exit from the dialog box and cancel button is used to exit without save. The menu list box shows a list of menu control we have created on the form. We edit and existing control position in the menu system by selecting it in the list box and them using one of these button. Here is a description of each button.

  1. Right arrow: – When we click this button the selected menu control moves down one level in the menu system hierarchy. If the selected menu control is a menu name which this button is selected, it becomes a menu command. If it is a menu command when this button is clicked, it becomes a sub menu command.
  2. Left arrow: – When we click this button the selected menu control moves up on label in the menu system hierarchy. If the selected menu control is a sub menu command when this button is clicked, it becomes a menu command. If it is a menu command when this button is clicked, it becomes a menu name.
  3. Down arrow: – When we click this button the selected menu control moves down one position in the list.
  4. Up arrow: – When we click this button the selected menu control moves up one position in the list.
  5. Next: – When we click this button the control below the currently selected control becomes the selected control.
  6. Insert: – When we click this button a new menu control is inserted into the menu system directly above the currently selected control.
  7. Delete: – When we click this button the selected menu control is deleted.
Advertisements