Most applications that you develop in VB do
not need to be running constantly in the background. However, there
are times when you will need an application to run unsupervised. It
is often a good idea to place an icon in the System Tray (the area
on the lower-right end of your screen, on the taskbar) for these
types of applications.
To do this in VB, you first need to set up a User Defined Type
(UDT), and declare constants and functions to handle the API calls
that will be required. The best place to put this code is in a
seperate MODULE:
Next, you need to create an ICON (.ico) to associate with your
application. See this tutorial for
instructions on creating icons.
Now that you have created your icon, you need to set the
properties on the form(s) of your VB Project. For every FORM that
you want to respond to events in the System Tray, you need to set
these properties:
- Icon: Select the file path to your newly created icon
- Minbutton: True
- ShowInTaskbar: False (because you want the icon to show up in
the system tray, not the taskbar)
You also need to set up a menu for your form, using the Menu
Editor. Enter the following menu items, with the appropriate
properties checked:
- &Systray (Enabled, Not Visible, Top Level)
- &Restore (Enabled, Visible, Second Level)
- &Exit (Enabled, Visible, Second Level)
The menu items on the second level will show up when you
right-click your icon in the System Tray.
Finally, you need to write out the code for each form that you
want to handle events from the System Tray:
Related Links: Creating the Favicon
Want to discuss this article, or other development issues? Visit our
message boards!
Or contact us directly with a comment or question on this article: click here !
|