View
217
Download
0
Category
Tags:
Preview:
Citation preview
TheProfessional
Touch
Programming Right from the Start with Visual Basic .NET 1/e
10
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 2
Objectives
• Create and work with menus
• Create and work with Font and Color Dialog boxes
• Create and work with Print and PrintPreview Dialog boxes
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 3
Objectives (cont.)
• Perform simple text file input/output (I/O)
• Add Multimedia controls to your application
• Develop applications that combine standard dialogs, text file I/O, and multimedia
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 4
10-1 Menus
• A menu is a list of common operations presented to the user in a well-defined, system-universal format.
• The main menu is a horizontal menu that is permanently visible during the lifetime of the application.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 5
Creating Menus
• Visual Studio provides a Menu Designer that makes it easy to add a main menu to your application.
• The first step is to add a MainMenu control to your solution.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 6
Creating Menus (cont.)
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 7
Writing Code for Menu Items
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 8
10-2 Standard Dialog Boxes
• Another professional touch for your application is the use of standard dialog boxes for tasks such as working with fonts, colors, printing, and files.
• Dialog boxes can be created at design time or programatically as they are needed.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 9
10-3 Font and Color Dialogs
• The ColorDialog control represents a preconfigured dialog that displays the standard “Color” dialog box, allowing the user to select a color or define a custom color.
• To display the color dialog box, call the ShowDialog method.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 10
10-3 Font and Color Dialogs (cont.)
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 11
10-3 Font and Color Dialogs (cont.)
• The FontDialog control represents a preconfigured dialog that displays the standard Font dialog box.
• To display the font dialog box, call the ShowDialog method.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 12
10-3 Font and Color Dialogs (cont.)
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 13
10-4 Text File Input/Output
• The OpenFileDialog control represents a preconfigured dialog for selecting a file to be opened.
• The SaveFileDialog control shares much of the behavior of the OpenFileDialog control, including capturing a string value for FileName.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 14
Streaming Data
• To transfer data between the application and a file, you must write your own data transfer logic.
• The StreamReader class is designed for character input.
• The file to be read from can be opened using the File.OpenText(path) function.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 15
Streaming Data (cont.)
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 16
Streaming Data (cont.)
• The StreamWriter class is also designed for character output.
• The file to be written to can be assigned using the File.CreateText(path) function.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 17
Streaming Data (cont.)
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 18
10-5 Print andPrintPreview Dialogs
• The PrintDialog control is a preconfigured dialog box used to select a printer, choose the pages to print, and determine other print-related settings in Windows applications.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 19
10-5 Print andPrintPreview Dialogs (cont.)
• The PrintPreview control is a preconfigured dialog box used to display how the document will appear when printed.
• The PageSetupDialog control is a preconfigured dialog box that allows users to manipulate page settings, including margins and paper orientation.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 20
10-6 Multimedia
• The Windows Media Player control plays video and sound files in many different formats.
• The media player is not part of the standard toolbox, but it can be added from the Tools menu.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 21
Chapter Summary
• A menu is a list of common operations presented to the user in a graphical format.
• Visual Studio provides a series of dialog controls, which provide significant functionality with little effort.
Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 22
Chapter Summary (cont.)
• The StreamReader class is designed for character input.
• The Windows Media Player control plays video and sound files in many different formats.
TheProfessional
Touch
Programming Right from the Start with Visual Basic .NET 1/e
10
Recommended