Results 1 to 8 of 8

Thread: [VB6] NotifyIcon - Tray Icon Control

  1. #1

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Exclamation [VB6] NotifyIcon - Tray Icon Control

    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!
    Attached Files Attached Files
    Last edited by dilettante; Jan 15th, 2012 at 02:43 AM. Reason: Updated once again!

  2. #2
    New Member
    Join Date
    May 2010
    Posts
    8

    Re: [VB6] NotifyIcon - Tray Icon Control

    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!!

  3. #3

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    In the demo mnuSys is the popup menu used. Just add the items you want to that menu.

    This is the menu that you pop up within the ContextMenu event. Visible is unchecked in the IDE so that it doesn't appear in the menu bar of the Form.

  4. #4

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    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

  5. #5

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    Ok, who will be the first to break it?

  6. #6

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    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.

  7. #7

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    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().
    Attached Files Attached Files

  8. #8

    Thread Starter
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [VB6] NotifyIcon - Tray Icon Control

    Regarding version 5 above:

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width