Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.

Similar presentations


Presentation on theme: "Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start."— Presentation transcript:

1 Slide 1 Using Menu Bar & Common Dialog Boxes

2 Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start the Menu Editor in any of three ways: –click the Menu Editor button on the toolbar; –choose Tools, Menu Editor; –or press Ctrl+E. The Menu Editor then appears, as:

3 Slide 3 Menu Controls v Each line of text (menu item) in a menu is a Menu control with the following properties: –Caption: The caption is the actual text that is displayed in the menu item. –Name: This property is used to identify the menu item in code. –Index: If this menu item is part of control array, –Shortcut: With this property, you can define shortcut key combinations that allow your users to select a menu item with one keystroke, –Checked: If this property is True, a check mark appears to the left of the menu item’s caption to indicate, –Enabled: This property can be set to False if its associated action isn’t appropriate at a particular time. –Visible. This property determines whether the menu item can be seen.

4 Slide 4 Multiple-Level Menus v Menus in Windows-based applications contain multiple levels of commands. v Top-level menu items are the ones that are visible in the program’s menu bar. v Clicking a toplevel menu item opens that item’s submenu. v You can then insert separator bars to group the related functions.

5 Slide 5 Writing Code for the Menu Items v A menu item handles only one event: the Click event. v This event is triggered when a user clicks the menu item, or when the user selects the item and presses Enter. v To add code to a menu item’s Click event procedure, first select the menu item on the form by clicking the item, then write the event procedure.

6 Slide 6 Other Properties v The Visible and Enabled Properties: –mnuFileSave.Enabled = True –mnuFileSendTo.Enabled = True –mnuFilePrint.Enabled = True –mnuEdit.Visible = True v The Checked Property –mnuOptionsText.Checked = True –mnuOptionsText.Checked = Not mnuOptionsText.Checked

7 Slide 7 CommonDialog Control v Using a single CommonDialog control, you have access to the following standard Windows dialog boxes: –Open. Lets the user select the name and location of a file to open. –Save As. Lets the user specify a filename and location in which to save information. –Font. Lets the user choose a base font and set any font attributes that are desired. –Color. Lets the user choose from a standard color or create a custom color for use in the program. –Print. Lets the user select a printer and set some of the printer parameters. –Help. Takes the user into the Windows Help system.

8 Slide 8 CommonDialog Control v To access the CommonDialog control, you might first have to add it to your project (and to the Toolbox) by selecting it from the Components dialog box. v You can access this dialog box by choosing Project, Components. From there, select Microsoft Common Dialog Control 6.0 in the Controls list and click OK.

9 Slide 9 The File Dialog Boxes v File dialog box can be used in either of two modes: Open and Save As. v Opening Files: –cdlTest.ShowOpen –Msgbox “You Selected “ & cdlTest.FileName & “ to be opened.” v Saving Files: –cdlTest.ShowSave –Msgbox “You Selected “ & cdlTest.FileName & “ to be saved.” v Specifying File Types with the Filter Property: –cldTest.Filter = “Word Documents (*.doc)|*.doc” –cdlTest.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*” –cdlTest.ShowOpen

10 Slide 10 The Font Dialog Box v Flags property v If you do not set a value for the Flags property, you get an error message stating that no fonts are installed. v Example: –cdlTest.Flags = cdlCFBoth + cdlCFEffects –cdlTest.ShowFont –lblTest.Font.Name = cdlTest.FontName –lblTest.Font.Size = cdlTest.FontSize –lblTest.Font.Bold = cdlTest.FontBold

11 Slide 11 The Font Dialog Box v Setting a text box font –Set txtAddress.Font = txtName.Font

12 Slide 12 The Color Dialog Box v You set the Flags property to the constant cdlCCRGBInit and then invoke the control’s ShowColor method. –cdlTest.Flags = cdlCCRGBInit –cdlTest.ShowColor –Form1.BackColor = cdlTest.Color


Download ppt "Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start."

Similar presentations


Ads by Google