Important alert: (current site time 7/16/2013 2:26:18 AM EDT)
 

winzip icon

Systray Icon (7-17-07 IMPORTANT)

Email
Submitted on: 7/24/2007 1:27:57 PM
By: Cobein 
Level: Beginner
User Rating: By 12 Users
Compatibility: VB 6.0
Views: 18667
 
     Reuploaded, last post is not accessible ??? I found a big bug concerning the recovery function now is working right, please if you are using and old version replace it. Major rewrite, additions and bug fixes, added support for windowless projects, class arrays windows 9x balloon, 3 new methods to load icons from resource files, from files and to extract them from dlls, exes. Fixed the balloontimeout and problems with popup menus. Better examples, add no window example, and multiple icons. Ive seen a lot of systray icon codes around here, but this one have everything, all the events including balloon close and balloon click all the properties you need to customize it, and a recovery function that ensure the icon will be shown even after an explorer crash, and is all in single class ready to be added to your projects, it uses LaVolpe and Paul Caton self subclass and callback. Updated: Added balloon timeout/nosound, fix some bugs and modified the recovery function Enjoy it!
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/6/2007 1:01:38 PMLaVolpe

Just a note: There is a much easier, less traffic-congested way of restoring after explorer crash than using a timer.
Tip: RegisterWindowMessage("TaskbarCreated")
(If this comment was disrespectful, please report it.)

 
7/6/2007 3:42:02 PMBody_of_Rays

Yes. I tried and is the best Systray code ever. Very easy to use and understand. 5 globes for you.
(If this comment was disrespectful, please report it.)

 
7/6/2007 11:54:00 PMM1K3

Really nice code... esp since you have a 'front end' to show how the class is used - much better than most I've seen - Thanks!
(If this comment was disrespectful, please report it.)

 
7/7/2007 3:17:08 AMThe typist

Great work! Nicely done.

Just one thing I would like to have. A balloon timeout where you could set the timeout in millisecs.
(If this comment was disrespectful, please report it.)

 
7/7/2007 3:28:11 AMLight Templer

Very good thing! A screenshot would be helpful ;-) Regards and my ***** - LiTe
(If this comment was disrespectful, please report it.)

 
7/7/2007 4:37:57 AMRuturaaj

Your code works as it says. Quality Submission indeed. However, one thing you missed out (or don't know, at least I didn't notice it then) ... Balloon Message Auto-close time. If it's not implemented as yet then please add this property as BalloonAutoClose As Long. If set to -1, do not auto-close; else run the API based timer internally by any method you want and then auto-close Balloon tool-tip. What you think? If you update your code, then will you please notify me (mailme_friends@yahoo.com)??
(If this comment was disrespectful, please report it.)

 
7/9/2007 7:03:18 AMBody_of_Rays

A tip: On sub BalloonShow, Optional ByVal bNoSound As Boolean = False

A bug: When you create a popup menu on systray mouse up(with right button), the menu doesn't disappear until you click somewhere in the form. I think the correct, is disappear when you click somewhere in the screen, not only on the form. It only happens when you compile the project. In IDE it works perfectly. Thanks for the submission, it's great. Sorry for bad english.
(If this comment was disrespectful, please report it.)

 
7/9/2007 9:07:50 AMCarlos Alberto S.

Nice work. However in my point of view you could add high resolution icon support so you'll be really close to "has everything" statement. :)
Here's a sample code: txtCodeId=60510
Finally it's always nice to "delete a balloon" before showing a new one: it'll avoid balloon queue. Of course the user can use two of your code functions but I'm not sure everyone is aware of the balloon queue feature (which is really annoying). Maybe an option?
(If this comment was disrespectful, please report it.)

 
7/9/2007 11:42:37 AMLaVolpe

I think this might help a few: if your menu doesn't disappear when it is suppose to, call SetForegroundWindow passing the form's hWnd. Consider adding popup menu to your sample tray.

There is another icon option you can provide: NIIF_USER As Long = &H4
That makes the balloon icon the one used as the tray icon.
(If this comment was disrespectful, please report it.)

 
7/10/2007 1:50:33 AMCobein

Thanks guys for the comments and support, Im fixing and adding everything you said, I'll upload a new update soon.
(If this comment was disrespectful, please report it.)

 
7/10/2007 8:48:05 AMLaVolpe

If you are interested, there are other options you can provide, for example: property indicating if balloons are supported or not (Win9x). If not supported, maybe app may want to flash the tray icon to get users attention - email me for info on how to do that.
Look at my post txtCodeId=62605 for some other ideas. That project is huge but the sysTray classes are what might interest you. FYI. I have designed something similar to what you are doing, but for Rent-A-Coder, therefore, I can't post it here.
(If this comment was disrespectful, please report it.)

 
7/10/2007 2:52:41 PMPaul Turcksin

IMO The most complete and comprehensive systray icon class. Thanks for sharing this jewel. 5/5
(If this comment was disrespectful, please report it.)

 
7/12/2007 1:50:03 AMenmity

best systray i ever seen with vb. how about:

1. support a link style bollon text allow user to click to trigger BallonClick?

2. custom ballon background(pic/color tect)/title/text(color)?

(If this comment was disrespectful, please report it.)

 
7/12/2007 5:01:03 AMenmity

one more thing: DblClick event never triggered
(If this comment was disrespectful, please report it.)

 
7/12/2007 1:29:44 PMCarlos Alberto S.

@ Cobein

Let me say that your project is getting better and better. Here's another suggestion:

You can check if balloon is enabled or disabled in the registry. Sample code: txtCodeId=54577

5 globes!!!!!
(If this comment was disrespectful, please report it.)

 
7/12/2007 7:27:35 PMCobein

Carlos I tryed what you say about the registry and it doenst affect the balloon at all (XP SP2) maybe in other version it works.. ????
enmity: I have noproblems with the DblClick event, anyone else having this problem?
About the custom ballon... maybe in a future version. ;)
(If this comment was disrespectful, please report it.)

 
7/12/2007 7:28:59 PMCobein

Thakns to all for feedback and votes.
(If this comment was disrespectful, please report it.)

 
7/13/2007 10:02:52 AMCarlos Alberto S.

@ Cobein

The registry suggestion is just to include a procedure to check or not if the user has balloon enabled (note that it probably requires a log off or restart in order to such registry change takes effect).
(If this comment was disrespectful, please report it.)

 
7/13/2007 5:52:09 PMCobein

Carlos Ive chaged the value manually and using tweakUI, restarted the machine and nothing happens, it seems to work just for the tips and password boxes.
(If this comment was disrespectful, please report it.)

 
7/17/2007 5:41:36 AMenmity

just want to tell you that it could not come back to live after terminated the explorer.exe and run it again.
(If this comment was disrespectful, please report it.)

 
7/17/2007 5:50:22 AMenmity

and using the latest version, it correctly recreated. btw, it now triggers the DblClick, but NOT the Click event, very strange.
(If this comment was disrespectful, please report it.)

 
7/17/2007 3:50:53 PMCobein

enmity: I messed up the recovery function, now is fixed. About the events, theres no Click event on the class, just mouse down and mouse up, you can use the mouse up instead of the click.
(If this comment was disrespectful, please report it.)

 
7/17/2007 9:50:20 PMenmity

sorry, maybe I did not remember correctly. just forget it. as long as it works all great:)
(If this comment was disrespectful, please report it.)

 
7/25/2007 1:56:44 PMGláucio

Nice code dude. 5 Globs ;)
(If this comment was disrespectful, please report it.)

 
7/26/2007 11:29:23 AMCobein

Thanks Gláucio, hehe next time make sure what you vote ;)
(If this comment was disrespectful, please report it.)

 
8/16/2007 12:16:06 PMBody_of_Rays

Hi Cobein, i made this to get the state of the SysTrayIcon. It's very simple, and, i think that sometimes can be very useful.

Private c_Visible As Boolean

Public Function IsVisible() As Boolean
IsVisible = c_Visible
End Function

***** Public Sub SysTrayShow...

if bShow then
.
.
c_Visible = True
else
.
.
c_Visible = False
end if
(If this comment was disrespectful, please report it.)

 
8/17/2007 1:44:48 PMCobein

@ Body_of_Rays, thanks I never added anything to see the status of the icon or balloon because I though no one is gonna use it, but I was wrong! Ill add it soon. Thanks for the feedback.
(If this comment was disrespectful, please report it.)

 
11/19/2007 2:00:32 AMRana Sohaib

'well well Dear Friend Cobein,
'but when closing the application the program ENDS
'Please give me suggestion by closing the program it shows in the system tray,
'just like Windows Messenger, yahoo! Messenger,
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.