Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views5 pages

Unit 2

This document provides a detailed guide on creating and managing menus and Multiple Document Interface (MDI) applications in Visual Basic 6.0. It covers the use of the Menu Editor for designing menus, handling mouse events, and managing MDI parent and child forms. The document emphasizes the importance of event handling and dynamic menu management for user-friendly application interfaces.

Uploaded by

mohanapriya.k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Unit 2

This document provides a detailed guide on creating and managing menus and Multiple Document Interface (MDI) applications in Visual Basic 6.0. It covers the use of the Menu Editor for designing menus, handling mouse events, and managing MDI parent and child forms. The document emphasizes the importance of event handling and dynamic menu management for user-friendly application interfaces.

Uploaded by

mohanapriya.k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Unit 2

2.1 Menus in Visual Basic 6.0

It covers the fundamentals of menu design, implementation, and event handling, enabling developers to
build user-friendly and intuitive interfaces for their applications. We'll explore the Menu Editor, menu
properties, and code examples to illustrate the process of adding and customizing menus in VB6.

Creating Menus with the Menu Editor

The primary tool for creating menus in VB6 is the Menu Editor. To access it, open your VB6 project and go
to Tools > Menu Editor. The Menu Editor window will appear, allowing you to define the structure and
properties of your menus.

Menu Editor Interface

The Menu Editor interface consists of the following key elements:

 Menu Control List: This area displays the hierarchical structure of your menu. You can add, delete,
and rearrange menu items here.
 Caption: This field specifies the text that will be displayed for the menu item. Use the ampersand
(&) symbol before a letter to designate it as a shortcut key (e.g., "&File" will display "File" and allow
the user to press Alt+F to access the menu).
 Name: This is the programmatic name of the menu item, used to refer to it in your code. It's crucial
for handling events associated with the menu item.
 Visible: Determines whether the menu item is initially visible.
 Enabled: Determines whether the menu item is initially enabled (clickable).
 Checked: Determines whether a checkmark appears next to the menu item. This is often used for
toggle options.
 NegotiatePosition: Used for MDI (Multiple Document Interface) applications to control menu
merging.
 WindowList: Specifies whether the menu item should display a list of open MDI child windows.
 Index: Used for creating control arrays of menu items.
 Shortcut: Allows you to assign a keyboard shortcut to the menu item.
 HelpContextID: Associates a help topic with the menu item.
 HelpFile: Specifies the help file to use.

Adding Menu Items

1. Open the Menu Editor.


2. In the Caption field, enter the text for your first menu item (e.g., "&File").
3. In the Name field, enter a descriptive name for the menu item (e.g., mnuFile).
4. Click the Next button to add another menu item at the same level (e.g., "&Edit").
5. To create a submenu, click the Right Arrow button. This indents the new menu item, making it a
child of the previous item. For example, under mnuFile, you might add "&New", "&Open...",
"&Save", and "E&xit".
6. To create a separator bar, enter a single hyphen (-) in the Caption field. VB6 will automatically create
a separator.
7. Repeat steps 2-6 to create your desired menu structure.
Example Menu Structure

Here's an example of a common menu structure:

 mnuFile - &File
o mnuFileNew - &New
o mnuFileOpen - &Open...
o mnuFileSave - &Save
o - (Separator)
o mnuFileExit - E&xit
 mnuEdit - &Edit
o mnuEditCut - Cu&t
o mnuEditCopy - &Copy
o mnuEditPaste - &Paste
 mnuHelp - &Help
o mnuHelpAbout - &About...
2.2 Mouse Event

MouseDown:
This event occurs when a mouse button is pressed down while the mouse pointer is over a control.
MouseUp:
This event occurs when a mouse button is released after being pressed while the mouse pointer is over a
control.
MouseMove:
This event occurs when the mouse pointer is moved while over a control.
Click:
This event occurs when a mouse button is pressed and released over a control.
DblClick:
This event occurs when a mouse button is clicked twice in rapid succession over a control.

2.2.1 Event Arguments:


Mouse events typically provide arguments that give information about the event. For example, in the
MouseDown, MouseUp, and MouseMove events, you'll receive the following arguments:
Button: Indicates which mouse button was pressed (left, right, or middle).
Shift: Indicates the state of modifier keys (Shift, Ctrl, Alt).
 X: The horizontal coordinate of the mouse pointer relative to the control.

 Y: The vertical coordinate of the mouse pointer relative to the control.

Mouse events are only triggered when the mouse pointer is within the bounds of a control. You can use
the MouseLeave event (available in some custom controls) to detect when the mouse pointer leaves a
control.
MDI in VB 6.0

This document provides a comprehensive overview of Multiple Document Interface (MDI) applications in
Visual Basic 6.0. It covers the fundamental concepts, creation, management, and common techniques used
when developing MDI applications, including creating parent and child forms, handling events, and
managing menus.

Introduction to MDI

MDI, or Multiple Document Interface, is a graphical user interface paradigm that allows an application to
host multiple child windows within a single parent window. This approach is useful for applications that
need to display and manage multiple documents or views simultaneously, such as text editors, image editors,
and IDEs. In VB 6.0, MDI applications are created using a special type of form designated as the MDI
parent, which then hosts other forms as MDI child windows.

Creating an MDI Application in VB 6.0

The process of creating an MDI application in VB 6.0 involves the following steps:

1. Creating the MDI Parent Form:


o Start a new project in VB 6.0.
o In the Project Explorer, right-click on the project name and select "Add" -> "MDI Form".
This will add an MDI parent form to your project.
o This MDI form will act as the container for all child forms.

2. Creating MDI Child Forms:


o Add standard forms to your project by right-clicking on the project name in the Project
Explorer and selecting "Add" -> "Form".
o For each form that you want to be an MDI child, set its MDIChild property to True in the
Properties window. This designates the form as an MDI child, allowing it to be displayed
within the MDI parent form.

3. Displaying MDI Child Forms:


o To display an MDI child form, you need to create an instance of the child form and then use
the Show method. Typically, this is done in response to a menu click or button click event.

Managing MDI Child Forms

Managing MDI child forms involves handling events, arranging the forms within the MDI parent, and
accessing properties of the active child form.

Handling Events

MDI child forms can have their own event handlers, just like regular forms. These event handlers can
respond to user interactions, such as button clicks, text changes, and form activation.

Menu Management in MDI Applications

Menu management in MDI applications requires special attention because the menu structure can change
depending on the active MDI child form. The MDI parent form typically has a base menu structure, and
MDI child forms can add or modify menu items when they are active.
Creating Menus

Menus are created using the Menu Editor in VB 6.0. You can add menu items, submenus, and separators to
the menu structure.

Handling Menu Events

Menu events are handled in the same way as other events in VB 6.0. You can write event handlers for menu
clicks to perform specific actions.

Dynamic Menu Management

To dynamically manage menus based on the active MDI child form, you can use the WindowList property
of the menu item. Setting this property to True will automatically add a list of open MDI child forms to the
menu item. When a user selects a child form from the list, that form becomes the active form.

MDI applications in VB 6.0 provide a powerful way to manage multiple documents or views within a single
application. By understanding the concepts of MDI parent and child forms, event handling, menu
management, and form arrangement, you can create robust and user-friendly MDI applications. While VB
6.0 is an older technology, the fundamental principles of MDI design remain relevant in modern application
development.

You might also like