Page 208 - Open Soource Technologies 304.indd
P. 208
Event Driven Programming
Objectives
After studying this unit, you will be able to:
• Discuss designing menus using menu editor
• Explain Assigning access keys and shootcut keys
• Understand the separating menu items
• Discuss the controlling menus at run time
• Explain model and modeless dialog boxes
• Understand predefined dialog boxes uses
Introduction
Menus in Visual basic 6.0 are created using the Menu object defined in the VB Library. The
menu created so are flat Win98 style menus and do not support icons. Further they cannot be
created at runtime and require “Menu Editor”, modification though can be made during
runtime.
Visual Basic Editor (VBE) and create a custom dialog box. Creating your own dialog boxes, or
User Forms as they are officially called, we can save a lot of time when we need to acquire
information from users. Rather than displaying a series of input boxes to gather information and
then a series of message boxes to instruct the user, a custom dialog box can do a lot of the work
for us. And they’re not as hard to create and use as you might think. Custom dialog boxes are
not only useful for gathering information such as the user’s name or personal data. A user
recently wanted to create a series of tables, each table with a slightly varied format. He could
have recorded one macro for each type of table but a more efficient way would be to create a
custom dialog box that gathers optional information. Then that information could be transferred
into the various format settings so that one table building macro could create several different
types of tables.
9.1 Designing Menus Using Menu Editor
We can use the Menu Editor to create new menus and menu bars, add new commands to existing
menus, replace existing menu commands with your own commands, and change and delete
existing menus and menu bars.
9.1.1 To Display the Menu Editor
• From the Tools menu, choose Menu Editor –or– Click the Menu Editor button on the
toolbar.
This opens the Menu Editor, shown in Figure 9.1.
While most menu control properties can be set using the Menu Editor, all menu properties are
available in the Properties window. The two most important properties for menu controls are:
• Name — This is the name you use to reference the menu control from code.
• Caption — This is the text that appears on the control.
Other properties in the Menu Editor, including Index, Checked, and NegotiatePosition, are
described later in this unit.
202 LOVELY PROFESSIONAL UNIVERSITY