Thread: Is there a function to get how many tray icons there are and there text

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    Is there a function to get how many tray icons there are and there text

    Is there any win32 functions that can get how many tray icons there are displayed and the text of them?

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    There must be some way to do it.

    I was able to get the hwnd of the tray like this:
    Code:
        HWND hwndTaskBar = FindWindowEx(NULL, NULL, "Shell_TrayWnd", NULL);
        HWND hwndTray = FindWindowEx(hwndTaskBar, NULL, "TrayNotifyWnd", NULL);
    With that hwnd, I was able to kill the tray like so:
    Code:
    SendMessage(hwndTray, WM_DESTROY, 0, 0);
    Hopefully it'll come back when I reboot!

    Anyway, there should be some way of asking the tray what it contains. I'm not sure what kind of control it is or if it's a standard control at all (a species of toolbar maybe?).

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Tray icons are essentially programs that are running that have the window hidden. Note that you have to do more than hide or minimize your window to get your program into the tray but there really isn't anything special about the tray. I think that should give you a good start.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Quote Originally Posted by oogabooga View Post
    There must be some way to do it.

    I was able to get the hwnd of the tray like this:
    Code:
        HWND hwndTaskBar = FindWindowEx(NULL, NULL, "Shell_TrayWnd", NULL);
        HWND hwndTray = FindWindowEx(hwndTaskBar, NULL, "TrayNotifyWnd", NULL);
    With that hwnd, I was able to kill the tray like so:
    Code:
    SendMessage(hwndTray, WM_DESTROY, 0, 0);
    Hopefully it'll come back when I reboot!

    Anyway, there should be some way of asking the tray what it contains. I'm not sure what kind of control it is or if it's a standard control at all (a species of toolbar maybe?).
    thats cool , would there be away to select which 1 to close as it seems all have them have closed

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    The code I posted actually just closes the tray itself, not the programs whose icons are displayed in it. I don't know how to get the actual info about the programs. I recall being able to get the number of icons currently in the tray but that's it.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows task tray icons
    By xixpsychoxix in forum Windows Programming
    Replies: 8
    Last Post: 05-24-2008, 03:14 AM
  2. Tray Icons
    By MK4554 in forum Windows Programming
    Replies: 3
    Last Post: 07-04-2006, 03:23 PM
  3. Problems with audio functions, tray icons + more!
    By face_master in forum Windows Programming
    Replies: 0
    Last Post: 10-08-2002, 10:35 PM
  4. system tray icons
    By canine in forum Windows Programming
    Replies: 1
    Last Post: 05-14-2002, 03:51 PM
  5. System Tray Icons
    By ExDigit in forum Windows Programming
    Replies: 5
    Last Post: 01-08-2002, 05:26 PM