Another simple way to add "tray" icons (Notification Area icons) to VB6 Forms.
Supports balloon notifications. Should work back to Win95 (with the Shell Update) since it doesn't try to implement most of the new Windows 2000+ behaviors. Balloons require Windows 2000 or later though.
Does not rely on the MouseMove event!
See the comments at the head of NotifyIcon.ctl for usage details. Packaged in the attachment as a demo project.
Updated to be even easier to use. Now with IDE-safe subclassing!
Last edited by dilettante; Jan 15th, 2012 at 02:43 AM.
Reason: Updated once again!
Where can I make other menus for the icon in the system tray? You already have Use Form Icon (I want to get rid of), Restore (I want to change the caption) and Exit (I want to remove)
From 412mark412
BTW I'm only 12, so nothing ubercomplicated please!!
A discussion today got me to take another look at this. I found the error in my "safe subclassing," and added logic to clean up the tray icon on a crash as well. Also should handle downlevel OSes properly now (WinMe, Win98, Win95 or NT 4.0 w/Desktop Update).
NOW IDE-SAFE SUBCLASSING WITH NO ASM THUNKS REQUIRED, a VB plus API calls solution. Bulletproof? Not sure yet, but it's looking good!
Could stand a fresh test on Win98 after these changes, I don't have a Win98 VM handy right now. Looks good on Win98 by one report.
Last edited by dilettante; Jun 5th, 2011 at 06:01 AM.
Reason: Win9x update
New update to the attachment (above). Large Icon selection now supported.
Until XP dies away a bit more it isn't worth supporting the new popup window (Vista & later) or DPI-scaling capability (Windows 7 & later). You can add these yourself of course.
Last edited by dilettante; Jan 15th, 2012 at 02:48 AM.
Revisited this and discovered a problem testing on Win95. Seems there is a little glitch in the unicows library ("Microsoft Layer for Unicode") used in Win9x to provide "W" entrypoints.
In any case this is corrected in version 5 of NotifyIcon.ctl by alternately calling the "A" and "W" versions of Shell_NotifyIcon().
The changes are small enough that you should be able to just drop in the new NotifyIcon.ctl and .ctx and recomiple your existing Projects with no changes. The main "visible" change is that the BalloonShow() method returns a Boolean "success" value now where False means you're on a pre-Win2K OS. Existing programs can just ignore the result value, or be changed so they can deal with it some other way.
I haven't done a full test on all Windows versions but it tests OK on Win95 OSR2 w/Desktop Update, Vista SP2, and Win7 SP1.