Visual Basic.NET by Nitin Chopra
System Tray Icon
and Context Menus
Public Events
Click |
Occurs when
the user clicks the icon in the status area. |
Disposed (inherited from Component) |
Adds an event
handler to listen to the
Disposed event on the component. |
DoubleClick |
Occurs when
the user double-clicks the icon in the status notification area of
the taskbar. |
MouseDown |
Occurs when
the user presses the mouse button while the pointer is over the
icon in the status notification area of the taskbar. |
MouseMove |
Occurs when
the user moves the mouse while the pointer is over the icon in the
status notification area of the taskbar. |
MouseUp |
Occurs when
the user releases the mouse button while the pointer is over the
icon in the status notification area of the taskbar. |
Protected
Properties
DesignMode (inherited from Component) |
Gets a value
that indicates whether the
Component is currently in design mode. |
Events (inherited from Component) |
Gets the list
of event handlers that are attached to this
Component. |
Protected
Methods
Dispose |
Overloaded.
Overridden. See
Component.Dispose. |
Finalize (inherited from Component) |
Overridden.
Releases unmanaged resources and performs other cleanup operations
before the
Component is reclaimed by garbage collection.
In C# and
C++, finalizers are expressed using destructor syntax. |
GetService (inherited from Component) |
Returns an
object that represents a service provided by the
Component or by its
Container. |
MemberwiseClone (inherited from Object) |
Creates a
shallow copy of the current
Object. |
Ok,
enough of text, lets come to the point. If you look at the public
properties of the NotifyIcon class you roughly get an idea how everything
is going to be done. The
Icon property defines the icon that appears in the status area.
The Pop-up menus for an icon are addressed with the
ContextMenu property. The
Text property assigns ToolTip text to the icon. In order for
the icon to show up in the status area, the
Visible property must be set to true.
In
VB 6.0 you needed to add a picture box to the form and hook it using
Shell_NotifyIcon() windows API function. Here the picture box acted as
a container. In .NET we don’t need to do this. As you can see we
already have a public member Container which does this job.
Note: To be a container, the class must implement the IContainer
interface, which supports methods for adding, removing, and retrieving
components.
|