ICONS

Each form in a Visual Basic application has its own icon. A form’s icon is displayed on the left side of its title bar, in the system’s taskbar, and by applications such as the Task Manager and Windows Explorer.

Some of these applications display icons at different sizes. For example, Windows Explorer uses 32 × 32 pixel icons for its Large Icons view and 16 × 16 pixel icons for its other views. Toolbar icons come in 16 × 16, 24 × 24, and 32 × 32 pixel sizes. Windows uses still other sizes for different purposes. For more information on various pixel sizes used by Windows Vista, see http://msdn2.microsoft.com/aa511280.aspx.

If an icon file doesn’t provide whatever size Windows needs, the system shrinks or enlarges an existing image to fit. That may produce an ugly result. To get the best appearance, you should ensure that icon files include at least 16 × 16 and 32 × 32 pixel sizes. Depending on the characteristics of your system, you may also want to include other sizes.

The integrated Visual Studio icon editor enables you to define images for various color models ranging from monochrome to 24-bit color, and sizes ranging from 16 × 16 to 256 × 256 pixels. It even lets you build icon images with custom sizes such as 32 × 48 pixels, although it is unlikely that Windows will need to use those.

To use this editor, open Solution Explorer and double-click the My Project entry to open the Project Properties window. Select the Resources tab, open the Add Resource drop-down, and select Add New Icon. Use the drawing tools to build the icons. Right-click the icon and use the Current Icon Image Types submenu to work with icons of different sizes. Right-click and select New Image type to add new image sizes or color formats.


ICON-A-THON
The integrated icon editor works and is free but it’s fairly cumbersome. Many developers use other icon editors such as IconForge (http://www.favicon.com/iconforge.html), IconEdit (http://www.iconedit.com), IconEdit 2 (no relation between this and IconEdit, http://www.iconedit2.com), and RealWorld Cursor Editor (http://www.rw-designer.com/cursor-maker). Note that I don’t endorse one over the others.

To assign an icon to a form at design time, open the Windows Forms Designer and select the Icon property in the Properties window. Click the ellipsis button on the right and select the icon file that you want to use.

To assign an icon to a form at run time, set the form’s Icon property to an Icon object. The following code sets the form’s Icon property to an icon resource named MainFormIcon:

Me.Icon = My.Resources.MainFormIcon

Some applications change their icons to provide an indication of their status. For example, a process-monitoring program might turn its icon red when it detects an error. It could even switch back and forth between two icons to make the icon blink in the taskbar.

Application Icons

Windows displays a form’s icon in the form’s title bar, in the taskbar, and in the Task Manager. Applications (such as Windows Explorer) that look at the application as a whole rather than at its individual forms display an icon assigned to the application, not to a particular form. To set the application’s icon, open Solution Explorer and double-click the My Project entry to open the Project Properties window. On the Application tab, open the Icon drop-down list, and select the icon file that you want to use or select <Browse . . . > to look for the file you want to use.

Notification Icons

Visual Basic applications can display one other kind of icon by using the NotifyIcon control. This control can display an icon in the system tray. The system tray (also called the status area) is the little area holding small icons that is usually placed in the lower-left part of the taskbar.

The control’s Icon property determines the icon that it displays. A typical application will change this icon to give information about the program’s status. For example, a program that monitors the system’s load could use its system tray icon to give the user an idea of the current load. Notification icons are particularly useful for programs that have no user interface or that run in the background so that the user isn’t usually looking at the program’s forms.

Notification icons also often include a context menu that appears when the user right-clicks the icon. The items in the menu enable the user to control the application. If the program has no other visible interface, this may be the only way the user can control it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.107.142