How do I get my homemade program into the SysTray?

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Anybody know how to add a program to the StartUp folder and have it land in the Systray?

I'm a beginning programming student, and I just wrote a fun little .exe in VB -- an Alarm Clock / Timer. Simple form that you type in the time you want the alarm to go off, or the number of minutes you want to wait till the timer goes off, giving a messagebox on the screen -- "Time's up!"

OK, I compiled it and created an icon on the DeskTop to run it, but I'm really curious -- what is it about the Systray programs that land them there instead of the TaskBar? I have several that I got from the internet, and I understand the StartUp folder is where you can put something to have it run at startup, but I just don't know anything about the Systray.

 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I looked at the code, and got lost. It's a bit over my head. I copied it into the VB IDE and came up with some errors I didn't know what to do with.

I got the Mabry control, and added it to my program, cool! It worked. I added the icon to the StartUp folder and it loads at boot, with a little alarm clock icon I chose, in the Systray. Clicking on it brings up my homemade form for the alarm-timer. Good! But I can't yet figure out how to make it so that when I close down the form on the screen, the program stays "alive". I found a way to keep the icon in the tray, adding

Private Sub Form_Terminate()
TrayX1.IconVisible = True
End Sub

but it's "dead", meaning I guess that the last command it executed before dying was to stick the icon in the tray. I'm just noodling around here. As I said, I'm a student, scratching my head a lot, trying this and that. VB has so much behind the scenes, and I explore by looking at things and saying, well, the terminate procedure looks like a place to try setting the IconVisible property to true, let's try that. I was pleased with myself for figuring out how to add a right-click menu that worked to Exit the program.

But I still haven't found the trick to keep the program alive, except to minimize it on the taskbar. I'm trying to get it to close but remain in the systray available to be clicked up agin.

Clues?
 

DJ_D

Member
Oct 11, 1999
193
0
0
I did this once before in C++, and the way I did it was to first create the icon in the system tray, and then catch the event when somebody clicks on the X icon on the title bar and instead of closing the window just hide it. Then when somebody clicks the icon in the tray, make your window visible again.
 

Delusion2001

Banned
Feb 13, 2001
1,370
0
0
you need to set a command so taht when the form closes or terminates, it just miniizes the program

good luck
 

cybrphreak

Member
Dec 31, 2000
60
0
0
Felcha-

If you wanna wait until later tonight, I'll figure it out. I'm thinking something along these lines:

Form1_QueryUnload
cancel = 0 'cancels the close option
me.hide 'hides the form

but I'll have to test it to be sure.

-Cybr