23
The Professional Touch Programming Right from the Start with Visual Basic .NET 1/e 10

The Professional Touch Programming Right from the Start with Visual Basic.NET 1/e 10

Embed Size (px)

Citation preview

Page 1: The Professional Touch Programming Right from the Start with Visual Basic.NET 1/e 10

TheProfessional

Touch

Programming Right from the Start with Visual Basic .NET 1/e

10

Page 2: The Professional 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

Page 3: The Professional 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 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

Page 4: The Professional 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 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.

Page 5: The Professional 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 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.

Page 6: The Professional 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 6

Creating Menus (cont.)

Page 7: The Professional 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 7

Writing Code for Menu Items

Page 8: The Professional 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 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.

Page 9: The Professional 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 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.

Page 10: The Professional 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 10

10-3 Font and Color Dialogs (cont.)

Page 11: The Professional 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 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.

Page 12: The Professional 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 12

10-3 Font and Color Dialogs (cont.)

Page 13: The Professional 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 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.

Page 14: The Professional 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 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.

Page 15: The Professional 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 15

Streaming Data (cont.)

Page 16: The Professional 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 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.

Page 17: The Professional 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 17

Streaming Data (cont.)

Page 18: The Professional 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 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.

Page 19: The Professional 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 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.

Page 20: The Professional 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 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.

Page 21: The Professional 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 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.

Page 22: The Professional 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 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.

Page 23: The Professional Touch Programming Right from the Start with Visual Basic.NET 1/e 10

TheProfessional

Touch

Programming Right from the Start with Visual Basic .NET 1/e

10