0 index
1 Designing Menus
2 How the menus are seen by VB
3 The menu design window
4 Designing the menu
5 The Shortcut
6 Accessing the code
7 Common Menu Guidelines
8 Common Dialogs
9 Example:
10 Actions of the Common Dialog
11 Methods
12 Example:
13 Properties set in design time
14 Properties changed in run time

outline
created using slideshow.cgi by Andy Harris















CSCI N331 Visual Basic: n331/vb12menudesign
1. Designing Menus
  • Menus should follow Windows standards (be along the top of the screen)
  • Have an option for the user to have quick access to an item (alt + underlined letter, i.e., File), also known as shortcut keys



































CSCI N331 Visual Basic: n331/vb12menudesign
2. How the menus are seen by VB
  • They are attached to the form and each menu item is a mini control with only a few properties
  • Each menu item has only a CLICKED event it recognizes



































CSCI N331 Visual Basic: n331/vb12menudesign
3. The menu design window
  • The component "CommonDialog" must be added to the list of tools by choosing Projects from the menu, then Components, and select the Common Dialog option from the list of items available



































CSCI N331 Visual Basic: n331/vb12menudesign
4. Designing the menu
  • The 'Menu Editor' is located on the horizontal toolbar on the left-hand side
  • This allows you to create an outline of the menu structure, change properties of the menu items
  • The user will see what the developer places in the caption area
  • Placing an & in front of a letter indicates that the next letter will be underlined and used for quick access (&File will show File)
  • Name is like a control name and should use mnuFile naming convention, each menu item MUST have a name



































CSCI N331 Visual Basic: n331/vb12menudesign
5. The Shortcut
  • This allows you to assign a Control combination or function key to the menu item
  • Checked: tells whether there is a check mark placed next to the item (TRUE or FALSE)
  • Enabled shows whether the user can access the item (TRUE or FALSE)
  • Visible shows whether the item is visible (TRUE or FALSE)



































CSCI N331 Visual Basic: n331/vb12menudesign
6. Accessing the code
  • Once you have your menu designed, it will appear at the top of your form, all you will need to do is click on the menu item's name to access the code window for the name you have chosen



































CSCI N331 Visual Basic: n331/vb12menudesign
7. Common Menu Guidelines
  • Items are usually 2-3 items deep, but can be deeper and usually less than 7-10 choices per menu
  • When possible, the first letter should be underlined and be related to a shortcut key



































CSCI N331 Visual Basic: n331/vb12menudesign
8. Common Dialogs
  • There are already dialog boxes existing in Windows
  • Many commands are used in various types of programs (Save, Open, Font, etc.)
  • Dialog boxes related to these commands are available as common dialogs
  • The Common Dialog Box Control works very differently from most controls
  • The control is NOT visible on the form (similar to the Timer - it's there but you don't see it)
  • The control is 'called' by the use of an action statement or a show method



































CSCI N331 Visual Basic: n331/vb12menudesign
9. Example:
  • CmDialog1.Action = 3
  • CmDialog.ShowColor



































CSCI N331 Visual Basic: n331/vb12menudesign
10. Actions of the Common Dialog
  • Same control can 'call' any of the dialogs depending on the value of the action property
  • ActionType of box
    1
    Open
    2
    Save
    3
    Color
    4
    Font



































CSCI N331 Visual Basic: n331/vb12menudesign
11. Methods
  • The common dialog control actions can also be controlled through methods. Many programmers find these easier to remember than use rather than the action property
  • Some methods are:
       ShowOpen
       ShowSave
       ShowColor
       ShowFont



































CSCI N331 Visual Basic: n331/vb12menudesign
12. Example:
  • CmDialog1.Action = 1
      is exactly the same as
    CmDialog1.ShowOpen



































CSCI N331 Visual Basic: n331/vb12menudesign
13. Properties set in design time
  • Filter - this is used in file dialogs to determine how dialog will isolate files
  • Format - .TXT(TextFiles)|.TXT (there is no space on either side of | which is the 'pipe' character
  • This is usually located on the backslash key, sometimes it looks like a broken vertical line



































CSCI N331 Visual Basic: n331/vb12menudesign
14. Properties changed in run time
  • The properties of a common dialog are used for communication between the user and the programmer
  • Common dialogs DO NOT do actual file manipulation, color changing, or whatever
  • They bring up dialog boxes for the user to select these things and they store the user's choice in the properties of the common dialog object



































outline

Designing Menus

How the menus are seen by VB

The menu design window

Designing the menu

The Shortcut

Accessing the code

Common Menu Guidelines

Common Dialogs

Example:

Actions of the Common Dialog

Methods

Example:

Properties set in design time

Properties changed in run time