📄 vcg09.htm
字号:
<P>The datasource for the forms for Figure 9.3 is NorthWind.MDB, which is supplied with Access. Data for the year 1994 is shown in these examples because 1994 is the latest year for which 12 months of data is available in NorthWind.MDB. If you installed NorthWind in a location other than the default directory (usually \MSOffice\Access\Samples), you need to change the values in the code that point to the datasource (or be sure that your definition of the NorthWind datasource is the same as the one used here).
<BR>
<P>The following list describes the design principles embodied in the decision-support form shown in Figure 9.3.
<BR>
<UL>
<LI>The form uses a white background to present a contrast with colored objects. Large areas of white or vivid colors are distracting to the user of an application. Avoid dark-colored backgrounds. The preferred background is light gray.
<BR>
<BR>
<LI>There is no opening form or <I>splash screen</I>. A splash screen is a form or design element that identifies the application. (An example of a splash screen is the copyright message that appears when you first launch Word for Windows, Excel, or other mainstream Windows applications.) You might need an initial login window to obtain the password required to start the application and to log the user into a secure database.
<BR>
<BR>
</UL>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>If your application is copyrighted, you might need to include a splash screen to display the program's copyright information. You should consult with your legal advisor for the requirements you must follow to protect your copyright.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<UL>
<LI>The buttons present large targets for the mouse. Each button has an icon and an optional caption to explain the purpose of the button. In the status bar, a single line of help is provided for each of the toolbar buttons. Toolbars that substitute for common menu choices are common in today's Windows applications. The toolbar in Figure 9.3 is modeled on the Microsoft Mail application, which is an example of a Windows application with a simple and attractive user interface.
<BR>
<BR>
<LI>Three-dimensional group pushbuttons, provided by Visual C++, are used to indicate the user's current display choice or other operation. Disabled buttons are indicated by replacing colored bitmap elements with a grayscale image that, except for color, is identical to the icon when the button is enabled.
<BR>
<BR>
<LI>A menu is provided to let the user make choices that aren't implemented by buttons. In production applications, a menu choice duplicates the action of each button. Enabling and disabling menu choices follows the same pattern as that employed for the corresponding buttons.
<BR>
<BR>
<LI>The form is designed to occupy much of the display area in normal mode. If you're designing the application for presentation, set the size of the form to the entire display area.
<BR>
<BR>
<LI>The preferred user interface for decision-support applications is a <I>single document interface</I> (SDI) form that displays a single document (a graph, a chart, or a table) with common menus and toolbars. Showing and hiding objects on a single form is typical in this type of application.
<BR>
<BR>
</UL>
<P>The form shown in Figure 9.3 serves as the foundation of the form designs for the majority of the decision-support sample applications presented in this book.
<BR>
<P>I have created only bar charts for this chapter. If you want to, you can add line and pie charts yourself.
<BR>
<BR>
<A NAME="E70E56"></A>
<H5 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Maintaining Consistency</B></FONT></CENTER></H5>
<BR>
<P>According to Ralph Waldo Emerson, "A foolish consistency is the hobgoblin of little minds." However, this doesn't apply to computer applications. Having both <I>internal</I> and <I>external</I> <I>consistency</I> of the user interface is a principal requirement of a properly designed Windows application.
<BR>
<UL>
<LI><I>Internal (endogenous) consistency</I> implies that the appearance of all of the forms and the behavior of all of the controls on the forms that constitute your application are similar. If the behavior of a button or menu choice needs to differ under certain conditions, change the appearance of the icon (change a color, for example) or alter the caption for the menu choice.
<BR>
<BR>
<LI><I>External (exogenous) consistency</I> means that the appearance and behavior of your application is similar to other mainstream Windows applications. If, for example, your client primarily uses Microsoft applications, the appearance and operational characteristics of your application should be modeled on the current version of Excel, Word for Windows, Microsoft Mail, or Microsoft Access.
<BR>
<BR>
</UL>
<P>You need to meet the following criteria to maintain internal consistency:
<BR>
<UL>
<LI>All the forms that constitute the application should have a similar appearance. Background colors, typeface families, and the size of display elements should remain constant throughout the application. It's easier to read serif fonts, such as Times New Roman and MS Serif, than fonts without serifs (sans serif), such as Arial and MS Sans Serif. Use the bold attribute for label captions, graph and chart labels and legends, and numerical values in grid controls. Use standard TrueType fonts that are supplied with Windows 95 or Windows NT; let users change the fonts to their own favorites if they want to.
<BR>
<BR>
<LI>The location and sequence of navigation devices should remain constant for all places. Buttons and menu choices that appear in more than one place always appear in the same sequence and in the same position (where feasible).
<BR>
<BR>
<LI>Icons that are used to identify objects or operations should have the same appearance in all places. If the images you use for icons adequately represent and distinguish the objects or operations, you can eliminate captions in second-level dialog boxes where you need more buttons than will fit in a single row if the buttons have captions.
<BR>
<BR>
</UL>
<P>Here are the rules for maintaining external application consistency:
<BR>
<UL>
<LI>Choose a mainstream Windows application as the model for your application's toolbar. Microsoft Word and Microsoft Mail are good choices as model for toolbar forms, and Excel's standard toolbar represents a good starting point for forms that need more than eight buttons.
<BR>
<BR>
<LI>Buttons with icons that are identical to or similar to icons found in other mainstream applications should perform the same or similar functions in your application. Using as much of Visual C++'s default toolbar buttons as possible will lead to a consistent application.
<BR>
<BR>
<LI>When creating 32-bit applications with Visual C++ 4 (and later versions), implement the toolbar tool tips features to allow the application's user to navigate the toolbar.
<BR>
<BR>
<LI>Use a consistent font for button captions if you create a toolbar with big, captioned buttons. Microsoft uses the 8.25-point MS Sans Serif Roman font for most button captions and as the default typeface for numeric values; your application should follow suit. <I>Roman</I> is the term for a font with no attributes—for example, not bold, not italic, and not underlined. MS Sans Serif is a bitmapped font that closely resembles Linotype Corp.'s Helvetica typeface family.
<BR>
<BR>
<LI>Use a common menu and toolbar on an MDI parent form and employ MDI child forms to present graphs, charts, and grid controls based on your application's queries.
<BR>
<BR>
<LI>Microsoft common dialog boxes (used for opening and saving files, as well as for other common operations) and message boxes usually have a sculpted appearance and a light gray background. You need to declare and use the functions contained in CTL3DV2.DLL to add the Microsoft style to your common dialog boxes and message boxes when you write applications for earlier versions of Windows, such as Windows 3.1x.
<BR>
<BR>
</UL>
<P>Borland International's products use stylized OK, Cancel, and Help buttons for message boxes. If you want to duplicate Borland's button style, you'll need to create your own custom bitmapped buttons. (Windows applications that were created with the Borland C++ compiler have stylized OK buttons with an adjacent shadowed check mark that Borland includes in its resources library.)
<BR>
<BR>
<A NAME="E69E165"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Identifying Toolbar Button Functions</B></FONT></CENTER></H4>
<BR>
<P>Visual C++ supports the identification of toolbar buttons (and menu selections) in the status bar's output area. When you design the menu items, you need to provide only a prompt string, as shown in Figure 9.4. The part of the prompt string following the \n is the tooltip text.
<BR>
<P><B><A HREF="09vcg04.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg04.gif">Figure 9.4. A prompt for a menu item that includes tooltip information.</A></B>
<BR>
<P>It's difficult to create a collection of small icons (about 24x24 pixels) that unambiguously represents a variety of operations. Figure 9.5 illustrates the use of pop-up labels (usually called <I>tooltips</I>) that appear when the mouse pointer is positioned on the surface of the button. Tooltips are supported by Visual C++ 4's MFC 4.
<BR>
<P><B><A HREF="09vcg05.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg05.gif">Figure 9.5. Using a pop-up label to identify the purpose of a small toolbar button.</A></B>
<BR>
<P>Placing a pop-up label adjacent to the button with which it is associated is a better method of identifying the purpose of a button than displaying the same information in a status bar at the bottom of a form. No eye movement is necessary to read the adjacent label caption, whereas substantial eye movement is required to traverse the VDU from the top toolbar to the bottom status bar. Minimizing the eye movement required to accomplish each of the application's tasks is one of the principles of good user interface design, as shown in Figure 9.5.
<BR>
<BR>
<A NAME="E68E56"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Creating and Using Toolbars</B></FONT></CENTER></H3>
<BR>
<P>The documentation that accompanies Visual C++ describes how to use the graphics capabilities of Visual C++ but provides little or no practical advice for adding images to toolbar buttons and bitmap pushbutton controls. The following sections describe how to obtain the bitmapped images you need for your toolbar buttons, how to create Windows bitmap (.BMP) files with Windows Paint, and how to add the image contained in a .BMP file to a bitmap button.
<BR>
<BR>
<A NAME="E69E166"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Obtaining and Modifying Button Bitmaps</B></FONT></CENTER></H4>
<BR>
<P>Visual C++ includes a plethora of icons and bitmaps, shown in Figure 9.6, that you can use to decorate conventional and 3-D command and group pushbuttons. Some of these bitmaps will seem familiar because they are found in Microsoft's word processors and other applications. You can find these files in the \MSVC20\SAMPLES\MFC\CLIPART directory on the Visual C++ 2 CD or the \MSDEV\SAMPLES\MFC\GENERAL\CLIPART folder on the Visual C++ 4 CD.
<BR>
<P><B><A HREF="09vcg06.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg06.gif">Figure 9.6. The contents of the TOOLBAR_.BMP file.</A></B>
<BR>
<P>Each of the images in the TOOLBAR_.BMP file can be copied (using the clipboard) to an application's toolbar.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>These files aren't available with Visual C++ 4.0. If you have the subscription edition of Visual C++, you might want to retain your prior CDs.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BR>
<A NAME="E70E57"></A>
<H5 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Using the Image Editor Application to Create Button Bitmaps</B></FONT></CENTER></H5>
<BR>
<P>Visual Basic 4.0 includes a bitmap editing tool called Image Editor, located on the Visual Basic CD in the \Tools\Imagedit folder. (You might need to manually copy this folder from the CD to your hard disk.) You need to transfer the data in icon (.ICO) files to Windows Paint using the Windows clipboard, because you can't open an .ICO file in Windows Paint. The Image Editor, however, does permit you to directly open and edit .ICO files. Figure 9.7 shows the sample Mail.bmp file being edited in the Image Editor application.
<BR>
<P><B><A HREF="09vcg07.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/09vcg07.gif">Figure 9.7. The Image Editor application displaying the sample Mail.bmp file.</A></B>
<BR>
<P>Select Edit | Copy in the Image Editor to copy the entire icon to the clipboard in .BMP format. Open Paint, add a light gray background with the paint roller tool, and choose Edit | Paste to add the icon to your Paint image. You can alter the button bitmap's appearance using either the Image Editor or Paint's toolkit. In general, you might find it easiest to use the Image Editor, which automatically magnifies the .BMP or .ICO image you're working with.
<BR>
<BR>
<A NAME="E70E58"></A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -