Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

IMPLEMENTING THE PROGRAMMING LOGIC

Chapter 16

363

 

 

 

 

When the user clicks the mnuConfigure menu item in the context menu, the notify icon disappears and the Creative Learning form is displayed. In addition, the application appears in the taskbar.

8.To make the mnuExit menu item functional, add the following code to the Click event of the mnuExit menu item.

private void menuItem3_Click(object sender, System.EventArgs e)

{

Application.Exit();

}

When the user clicks the mnuExit menu item, the application terminates. In addition, the user can exit the application by clicking on the Exit button. You will learn to add code to the Exit button later in this chapter.

In addition to adding menu items to the ContextMenu control, you can add code that displays the application when the user double-clicks on the notification icon in the status area of the taskbar.

9.To display the application when the user double-clicks on the notification icon, add the following code to the DoubleClick event of the NotifyIcon control.

private void icoNotify_DoubleClick(object sender, System.EventArgs e)

{

icoNotify.Visible=false; this.ShowInTaskbar=true; this.Show();

}

Adding Code to the Exit Button

Add the following code to the Click event of the Exit button. This code will enable the application to terminate when the user clicks on the Exit button.

private void btnCancel_Click(object sender, System.EventArgs e)

{

Application.Exit();

}