Create a Blinking Icon in the System Tray

Category:
Forms and Controls
Type:
Snippets
Difficulty:
Advanced
Author:
Brice Richard

Version Compatibility: Visual Basic.NET

More information:
The form control NOTIFYICON component comprises the ability to display a single icon in the status notification area of the taskbar called the SYSTEM TRAY. It is used to alert users to an action or event that has occurred or to provide notification of a status change of some sort. To display multiple icons in the system tray, you must have multiple NOTIFYICON controls on your form - one for each icon to display. To set the icon displayed for a NOTIFYICON control, use its Icon property. Additionally, you can set the Text property of the control to display a tooltip when the user hovers the mouse over the icon. Code can also be written in 1 of 6 available event handlers within the NOTIFYICON control. The illustrated code shows not only how to display an icon in the system tray when a specific event fires, but to display it in an ostensible way - by adding an animated blinking effect to the control. The effect requires the use of the NOTIFYICON and TIMER controls, a connected ICON file, and appropriate code. This code has been tested for functional accuracy. ------------------------------- 1) Drag both the NOTIFYICON1 and the TIMER1 controls on to a form 2) In the NOTIFYICON control's ICON property, add any icon file of choice 3) In the NOTIFYICON control's TEXT property, type any short tooltip message 4) In the NOTIFYICON control's VISIBLE property, set it to FALSE 5) In the TIMER control's INTERVAL property, type 1000 in the box -----ALL OTHER DEFAULT PROPERTIES REMAIN AS IS----- 6) Type the code "Me.Timer1.Start()" within the event in which you want to fire the NOTIFYICON1 control (for example, a button CLICK event) 7) In the CLICK event of the NOTIFYICON1 event handler, type the code listed in the code window under STEP 7 8) In the TICK event of the TIMER1 control, type the code listed in the code window under STEP 8. The TICK event can quickly be accessed by double-clicking the TIMER1 control on your form 9) Save and run the program

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: