![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
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 developers part. If they are used as menu command accelerators, they will not work as users expect for text boxes. Menus That Present DialogsIf 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 applications 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. SeparatorsMany 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.
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 MenusThe following sections describe menus and commands that are fairly standard in Windows programming. If an applications 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.
|
|
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.
|