473,373 Members | 1,155 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,373 software developers and data experts.

system tray icon with popup menu

Hello,
I have often seen system tray icons that you click on and a popup menu
appears. Is it possible to do this in Visual basic.net or are there any
controls that allow this to be achieved.

Thanx in advance.

Robert
Nov 21 '05 #1
5 12330
"Robert Smith" <Ro*********@discussions.microsoft.com> schrieb:
I have often seen system tray icons that you click on and a popup menu
appears. Is it possible to do this in Visual basic.net or are there any
controls that allow this to be achieved.


That's possible with the components which are contained in the .NET
Framework class library:

<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/SimpleNotifyIcon.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Robert,
Matthew MacDonald's book "Microsoft Visual Basic .NET Programmer's Cookbook"
has a topic on creating a system tray program.

Basically: Rather than using a Form as the startup object, use a Component
instead.

Create a new Component class (use Project - Add Component). Add a NotifyIcon
to the component designer. Also add a ContextMenu object for the
NotifyIcon. When you click the menu, create and show the form. Remember to
put an Exit option on the menu.

Make the Component the startup object, adding a Shared Sub Main to the
component.

Public Class Component1
Inherits System.ComponentModel.Component

' Component designer generated code omitted.

Public Shared Sub Main
Dim app as New Component1
Application.Run()
End Sub

Private Sub menuOptions_Click(...) Handles menuOptions.Click
' this would be your settings dialog.
Dim dialog as New OptionsDialog
dialog.ShowDialog()
dialog.Dispose()
End Sub

Private Sub menuExit_Click(...) Handles menuExit.Click
Me.Dispose()
Application.Exit()
End Sub

End Sub

The problem is you cannot edit the menu from the Component Designer. What I
do is use cut & paste from a Form Designer onto the Component Designer to
get the menu to the component...

The call to Me.Dispose enables the icon to be removed from the system tray
right away rather then waiting.

Hope this helps
Jay
"Robert Smith" <Ro*********@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Hello,
I have often seen system tray icons that you click on and a popup
menu
appears. Is it possible to do this in Visual basic.net or are there any
controls that allow this to be achieved.

Thanx in advance.

Robert

Nov 21 '05 #3
There is a simple example in the VB.NET help. Just lookup NotifyIcon. There
is an article called: 'Associating a Context Menu with a Windows Forms
NotifyIcon Component', which is exactly what you want.
Nov 21 '05 #4
Crochie,
Obviously if you like work & extra typing you can create a menu completely
by scratch in code as that article suggests.

However! I prefer to use the designers to do the work for me. So my
suggestion of using Cut & Paste seems to be exactly what *I* want :-)

Thanks for the link! I will try to remember to include it with my sample, so
others will have both alternatives.

Hope this helps
Jay

"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
There is a simple example in the VB.NET help. Just lookup NotifyIcon.
There
is an article called: 'Associating a Context Menu with a Windows Forms
NotifyIcon Component', which is exactly what you want.

Nov 21 '05 #5
I understand what you mean, jay. Sometimes I use the designer & others, I
code it.

When it comes to either coding or using the properties window, I use code
99% of the time. It's the way to do things in my eyes.
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bonj | last post by:
Looking for a good example of how to show a popup menu in response to the user right-clicking on the icon in the 'taskbar notification area' (tray). I'm fine with creating the icon and responding to...
10
by: One Handed Man [ OHM ] | last post by:
If this is duplicated, I'm sorry because I cant find the original post I made today Anyway . . Now its my turn to ask a question I want to develop an app which will run in the system tray....
1
by: Luck | last post by:
Hi, could someone please lead me in the right direction? I'm trying to write a program which will reside on the system tray. I for the user to be able to: (1) See an icon in the system tray (2)...
1
by: Geraldine Hobley | last post by:
Hello, I have an icon in my system tray and I wish to call various functions from withing the tray which involve the application been maximized. The following event is on the system tray icon ...
10
by: Crouchie1998 | last post by:
Hello To All You Real Programmers Out There!! There is an application called: "Tray It" Webpage: ---------- http://www.teamcti.com/trayit/trayit.htm Direct Download:
2
by: flaper87 | last post by:
Hi everybody!!!! I am developing an aplication, and i want it to stay on the system tray, i found out how to put the icon, but i can minimize it there, What do i have to do?, I'm using python(of...
3
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
4
by: ewokspy | last post by:
I have a system tray icon with a context menu set to appear on right-click. On a right click the menu appears fine and I can select an option. The problem is that the event doesn't fire immediately....
3
by: holaboxdotcom | last post by:
Hey I'm pretty new to C# (started few hours ago) but i learn extremly fast, i have previous knowledge of php, javascript and flash. I have made my first simple application the way i want it,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.