Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Manning - Windows Forms Programming With CSharp.pdf
Скачиваний:
72
Добавлен:
24.05.2014
Размер:
14.98 Mб
Скачать

C H A P T E R

8

 

 

Dialog boxes

8.1Message boxes 225

8.2The Form.Close method 233

8.3Modal dialog boxes 237

8.4Modeless dialogs 252

8.5Recap 262

So far we have only used a single window in our MyPhotos application. We have changed its appearance in each chapter, adding controls such as a menu bar, status bar, and panel, but all controls, events, painting, and other activities have occurred within our one Form window. In this chapter we branch out.

The previous chapter introduced the Form class and demonstrated drawing and scrolling in both it and the Panel class. Both of these classes can be used to support intricate drawing interfaces from those seen in basic drawing applications such as Microsoft Paint to a full-fledged Internet browser window.

Another common use for Form classes is the creation of dialog boxes. The Form class, as well as the Panel class, allows other controls to be positioned and managed inside its boundaries. In this chapter we look at how dialog boxes are created for both simple message boxes and more complex custom dialogs. This will consist of the following topics.

Create simple message dialogs with the MessageBox class.

Discuss the use of Close and Dispose for Form objects.

Use the OnClosing method to intercept when a form or dialog box closes.

224