130 likes | 241 Views
prepared by James T. Perry University of San Diego. Ch5. Menus, Sub Procedures & Sub Functions. Menus and submenus Windows common dialog boxes Function procedures Sub procedures Creating Executable Files. Menus . Caption: Holds menu "words" Follow naming conventions: mnu + <menu name>
E N D
prepared by James T. Perry University of San Diego
Ch5. Menus, Sub Procedures & Sub Functions • Menus and submenus • Windows common dialog boxes • Function procedures • Sub procedures • Creating Executable Files
Menus • Caption: Holds menu "words" • Follow naming conventions: • mnu + <menu name> • mnu + <menu name> + <command name> • E.g., mnuFileExit, mnuEditClear or mnuFile • Submenu: menu within a menu
Defining Menus • Define menus: Tools, Menu Editor • Caption • Name (mnuMenuxxCommand) • Sub menus defined by indenting command • Menu and submenu captions use & before keyboard access key
Creating a Menu • Create a menu structure like this one: File Help Exit About 1. Type caption 2. Type name 3. Indent if necessary 4. Repeat as needed
Coding for Menu Commands • Build commands first • Then, double click each command to bring up its Click event procedure • You can modify menu order or command order by invoking Menu Editor again • Checked property: contains check—toggles on and off • Enabled property: command available or not based on the Enabled property
Standards for Windows Menus • Follow existing Windows standards File menu is leftmost menu in menu bar Help menu is rightmost menu in menu bar Use keyboard access keys; match them to existing ones Use keyboard shortcuts (Ctrl + P for print)
Common Dialog Boxes • You can use existing Windows dialog boxes by inserting the common dialogcontrol on your form • Common dialog box does: • Open, Font, Color, Save As, and Print • If it is not in your toolbox, then execute: • Project, Components, check the Microsoft Common Dialog Control 5.0
Common Dialog Boxes (cont'd) • Only need on Common dialog box/form • Code determines which of the possible dialog boxes is displayed • Use prefix “dlg” for name of control • Display dialog box: dlgCommon.ShowColor dlgCommon.ShowFont
General Procedures • General procedures respond when specifically called by other procedures • They are not event driven • They are used to “package” a commonly used series of instructions • Invoke general procedures by calling them • Select Tools, Add Procedure to insert one
Functions vs. Sub Procedures • Functions vary from sub procedures in one way: they return a value • One calls a general procedure by simply writing its name along with any arguments • Somewhere in the procedure, you must set the function’s name equal to the value to be returned
Creating Executable Files • You can convert your applications to executable (.EXE) • Execute File, Make . . . • You can select a special icon for your application, insert the company name, etc. via the Options button on the Make EXE File dialog box