System Tray

supermanzdead

Active member
Joined
Feb 23, 2006
Messages
31
Programming Experience
Beginner
I am working on a small application (hobbyist at programming) that will load in the system tray using an icon that I have created, when the mouse is over it it will display the system idle time.

Two issues for me, I cannot make the form load as an icon to the system tray, and I am having a hard time figuring out how to display the systems idle time. I am new to Visual Studio 2005, I have created quite a few applications with VS 2003 but nothing that involves the system tray...eventually I'd like to run a command if the system idle time reaches a predetermined time...but as you read up I'd like to just get a form to load into the system tray and display when the icon in the system tray is clicked
 
To make a form display an icon in the system tray you need to add a NotifyIcon component to the form in the designer. When you want the icon to be visible you set its Visisble property to True. When you want the form to be hidden you set its Visible property to False and its ShowInTaskbar property to False. If you want the form to start in the system tray then you need to call Hide instead of Show so that its Visible property is not set to True. If your form is the startup object then this is not an option so you have to do a little more work. In the designer set the ShowInTaskbar property to False and the WindowState property to Minimized. Now when your form is opened it will not be visible. You should also handle the Shown event and set the Visible property to False and the WindowState property to Normal.

As for clicking your icon, the usual thing to do is to handle the DoubleClick event and set the Visible property of the NotifyIcon to False and the Visible and ShowInTaskbar properties of the form to True. You need to set Text property of the NotifyIcon to have the something displayed when it is moused-over.
 
Back
Top