Tutorial: how to put stuff into SysTray

Squirm
09-20-2001, 11:05 AM
This seems to be a rather *hot* topic lately, putting an application icon into the System Tray. For those of you that know the code and understand it, thats great, for those that dont want to be dabbling into API, there is another way.....

On one of your Visual Basic install CDs (I have been told CD 3) you will find the following directroy: common\tools\vb\unsupprt\systray ...... in that folder you should find a SysTray project.

1) Open the project
2) Click 'File' on the menu
3) Click 'Make SysTray.OCX'
4) Compile the OCX to your Windows/System directory

now, thats the easy part..........

5) Open up your VB project
6) Click 'Project' on the menu
7) Click 'Components'
8) Scroll down until you find 'SysTray.OCX' or 'System Tray Icon Control' or similar
9) Check it and click OK

You should now see a new control in your controls tab - 'cSysTray'.. Add one anywhere on your form (it is not visible at runtime)...

10) Select your new control
11) Set the InTray property to True
12) Select an icon for the control.
13) Add a TrayTip if you wish (text that pops up when the mouse moves over the icon)

Now, your icon is setup ready for use.... it has the following events:

MouseDown, MouseUp, MouseDblClick, MouseMove

There, ready for use....... the icon will sit in the systray while the app is running and you can control what happens from it using the events....... in my app the following lines appear:

Private Sub clsSysTray_MouseDown(Button As Integer, Id As Long)
frmChat.Show
End Sub

have fun.........

Squirm
10-24-2001, 02:48 PM
It has occurred to me that compiling the OCX and using in this way can be a long way of doing things. In fact, since the control is in .ctl form, you can just as easily add the control to your normal project and it will then be compiled into the EXE, no need to distribute the OCX with the application.

I would recommend this idea more than compiling the OCX, as written above. You never know, you might learn a thing or two about user controls........

Garrett Sever
10-24-2001, 02:58 PM
However, keep in mind that by including the systray.ctl and the .bas files, you will no longer be able to stop execution of the source code while running the debugger. Doing so will take down the IDE with it, and you will lose anything since your last save.

You have been warned images/icons/wink.gif

Banjo
10-24-2001, 03:31 PM
I sometimes use a hybrid method. I use the OCX for development and alpha testing. I then re-compile with the ctl instead for the beta testing and final release. This gives the best of both worlds.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum