home account info subscribe login search FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Advanced Visual Basic Techniques
(Publisher: John Wiley & Sons, Inc.)
Author(s): Rod Stephens
ISBN: 0471188816
Publication Date: 06/01/97

Search this book:
 
Previous Table of Contents Next


An application should not use Ctrl-C, Ctrl-X, or Ctrl-V as accelerators. These keys are the standard accelerators for the text copy, cut, and paste commands, respectively. Normally these commands work automatically in all the text boxes in a Visual Basic application without any extra coding on the developer’s part. If they are used as menu command accelerators, they will not work as users expect for text boxes.

Menus That Present Dialogs

If a menu command presents a dialog box or message box, or if it requires other user input before it takes action, its caption should end with an ellipsis ... (three dots). This tells the user that the command will not execute immediately when it is selected. For instance, every application’s Open command should have an ellipsis because the user must always select the file before it can be opened.

Commands with an ellipsis should always be safe. The user should always have a chance to cancel the command before any action takes place. Usually this is easy because the command presents a dialog box that can include a Cancel button. Encountering a dialog that does not allow the user to cancel can be a horrible experience. The user is forced to agree to unwanted actions while the program continues remorselessly to an unwanted result.

Separators

Many applications use separators to create visible breaks in long menus. The breaks should group related commands and move potentially dangerous commands away from less dangerous commands. For example, accidentally selecting the Exit command can be quite frustrating. Even if the application correctly ensures that the data is safe, forcing the user to restart the application is annoying and time consuming. To make it less likely that the user will accidentally select the Exit command, Exit is placed at the bottom of the File menu and set apart from other commands by a separator.

Many applications group the commands in the File menu in these categories.

•  Creating, opening, or closing files
•  Saving files
•  Print preview, print setup, and printing
•  Loading recent files (discussed later)
•  Exiting

In Visual Basic a separator is created in the Menu Editor. A menu entry that has a single dash - as its caption is displayed as a separator. Even though the user cannot select the separator menu item, the item must have a menu name. Separators should have names such as mnuFileSep1, mnuFileSep2, mnuEditSep1, and so on, so that it is easy to tell what they are.

Some rare applications use a blank menu entry as a separator. In other words they create a menu item and leave its caption blank. This may cause some confusion because the user can select a blank menu item. To prevent this confusion applications should use separators with a dash for a caption instead.

Standard Menus

The following sections describe menus and commands that are fairly standard in Windows programming. If an application’s menus are reasonably standard, users will feel more comfortable with the application and will not waste time hunting for common commands.

The Menus.VBP project in the Ch1 directory contains a form that includes most of the standard menu commands described in the following sections. You can use this form as a starting point for forms in your applications. Copy Menus.FRM into your project directory, and add it to your project. Then you can remove any menu commands that you do not need and enter functions to support the others.

File The File menu contains commands that deal with files. Loading and saving data to files certainly belong here. By tradition, document printing and print management commands also belong here. Commands that affect the application as a whole, such as Exit, also usually go in the File menu.

Figure 1.9 shows a File menu. The standard mnemonic for this menu is the letter F. Standard entries in the File menu are listed below. Accelerators are shown in parentheses after the menu names.

New (Ctrl-N). Closes the current document and creates a new document. If the current document has been modified, the application should give the user a chance to save it or to cancel the New operation.
Open (Ctrl-O). Uses a file selection dialog box to allow the user to select a file to open. Closes the current document the same way the New command does.
Close. Closes the current document. For an SDI application this command closes the current document, much as the New and Open commands do. It then removes all the controls that represent a document so that the form is blank and it is obvious that no document is loaded. Many SDI applications do not provide a Close command. A few applications use the Close command to close the entire application. The majority of applications do not, however, and that makes this a very bad idea. If the user is accustomed to the Close command being relatively harmless, changing its meaning to something as potentially dangerous as exiting the application could be disastrous.


FIGURE 1.9  A File menu.

Save (Ctrl-S). Saves the current document. If that document does not yet have an associated file name, this command is the same as Save As.
Save As (Ctrl-A). Uses a file selection dialog box to allow the user to enter the name of the file in which to save the data.
Save All. For MDI applications, saves all open documents. For any that do not yet have associated file names, the application uses a file selection dialog to allow the user to select a file name. This command should not be used in SDI applications.
Print Setup. Allows the user to perform printer setup functions including selection of the printer, page orientation, and selection of other printer-specific options. Printing-related commands are described in Chapter 2.
Print Preview. Displays an image of what the document would look like if it were printed.
Print (Ctrl-P). Prints the current document. Some applications present a dialog allowing the user to select a printer, specify the number of copies, and so forth. In this case, the command’s caption should include an ellipsis because it presents a dialog. If the application provides a Print Setup command that allows the user to specify these options, this is not necessary. In that case, this command should immediately print the document with no dialog.
Recent file commands. These commands list the names of a few of the most recently accessed files. They are listed in order so that the most recently accessed file is listed first. While a document is loaded and has an associated file name, that document’s file is listed first. Most applications list the four most recent files, though a few programs allow the user to configure the application to list more or fewer files. Some applications place the recent file list after the Exit command, but this is not standard. It hides the Exit command in the middle of the menu where the user will have a harder time finding it. Instead, the recent file list should be placed immediately before the Exit command. Recent file lists are explained further later in this chapter.
Exit. If the current document has been modified, this command asks the user if it should save the changes. After the document has been saved, or if the user wants to discard the changes, this command exits the application. The standard mnemonic for this command is the second character x, though some applications use the initial E. Since Ctrl-X is the standard accelerator for the text cut operation, an application should never use Ctrl-X as a shortcut for the Exit command. Making a potentially dangerous command such as Exit easier to invoke accidentally is a bad idea in any case.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.