Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать

ASSIGN A NEW APPLICATION ICON TO THE MYPHOTOS PROJECT (continued)

 

Action

Result

 

 

 

2

Display the Property Pages

 

 

dialog for the project.

 

 

How-to

 

 

a. Right-click the MyPhotos

 

 

project.

 

 

b. Select the Properties item.

 

 

 

 

3

Make sure the General

 

 

properties under the

 

 

Common Properties heading

 

 

is displayed.

 

 

 

 

4

Click the Application Icon

 

 

item in the list of properties.

 

 

 

 

5

Assign the file

The next time the application is built, the resulting

 

“icons\Writing\BOOK02.ICO”

MyPhotos.exe file will display and employ the assigned icon.

 

in the common images

 

 

directory as the icon for the

 

 

application.

 

 

 

 

There is no visual indication of the change. Rebuild the application and check out the bin directory. The MyPhotos.exe program file is now displayed with the assigned icon.

12.5RECAP

This chapter jumped around the Windows Forms namespace to cover various topics related to application development. We began by talking about keyboard and mouse events, and made use of these events in our MyPhotos application. Keyboard event handlers receive a KeyPressEventArgs parameter for KeyPress events, and a KeyEventArgs parameter for KeyDown and KeyUp events. All mouse event handlers receive a MouseEventArgs parameter.

We also discussed the creation of image buttons. We saw how to create custom bitmaps using our precision drawing skills in Visual Studio, and placed these bitmaps on a button in the PhotoEditDlg form in the MyPhotoAlbum project.

Our final topic was the use of icons for the control box of a Form window, and the windows icon associated with an application. We discussed how to customize the icon for a form as well as an application.

Along the way we discussed cursors, including the Cursors class supported by Windows Forms. We briefly touched on resource files, and looked at some examples of .resx files and how Visual Studio accesses items within these files using members of the System.Resources namespace.

The final chapter in part 2 of the book will look at the ToolBar control and the use of tool tips.

RECAP

409

C H A P T E R

1 3

 

 

Toolbars and tips

13.1Toolbars 411

13.2Image lists 416

13.3Toolbar buttons 420

13.4Tool tips 430

13.5Recap 434

In this final chapter of part 2 of the book, we round out our discussion of basic Windows Forms programming with the ToolBar and ToolTip classes. You may wonder why these concepts were not presented earlier in our discussion, and they certainly could have been. The reason is either poor planning or clever organization—you decide which. These two concepts are not necessarily related, but they do make for a catchy chapter title.

Toolbars in Windows Forms applications are created using the ToolBar and ToolBarButton classes. We will look at these classes along with the ImageList class in the first three sections of the chapter. Image lists are used by toolbars and other controls to hold a set of images available for display within the control. The final section in the chapter will examine tool tips and the ToolTip class.

Specific topics we will look at in this chapter include:

Adding a toolbar to a window.

Creating toolbar buttons: push buttons, separators, dropdown menus, and toggle buttons.

Associating menu commands with a toolbar button.

410

Соседние файлы в папке c#