?
Solved

Repainting system tray

Posted on 1997-12-30
7
Medium Priority
?
556 Views
Last Modified: 2013-12-03
Greetings.  How do you make Win95 repaint the system tray?  I have some custom apps that do not properly remove their system tray icons when exiting, although if you subsequently wave the cursor over them in the system tray, they are deleted.  This makes the user think that the app is still running, when it is not.  I do not have the liberty to rewrite those apps, but I can put a periodic tray repaint in a new app that I am writing.  Doing an Invalidate(NULL, NULL, TRUE) to repaint the entire desktop doesn't do the trick.  Any suggestions? Thanks in advance.
0
Comment
Question by:danbind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1409724
First of all Do you call Shell_NotifyIcon(NIM_DELETE, ...) to remove icon. If you do and it doesn't help you can erase background in system tray only. It has unique class name TrayNotifyWnd and you can use FindWindow with this clss name to obtaing a window handle.
0
 

Author Comment

by:danbind
ID: 1409725
Thanks for the info.  This seems like it would work, but I believe the problem is this:  even on a repaint, the system tray thinks that the bogus icon should remain, as it was never properly deleted with the Shell_NotifyIcon(NIM_DELETE,...) message.  Upon return from a screen saver, the icon is redrawn.  When you move the cursor over the bogus icon, and the system tray does a callback to get the tooltip caption, it doesn't get one, so it deletes the icon.  You can test this by modifying a program that uses a system tray icon so that it doesn't delete its icon on exiting.  Run it, terminate it from the task list using CTRL+ALT+DEL, and observe.  It seems like one approach would be to ask the system tray to ping all of its icons for valid callback responses (but I can't find any documentation on this).  I'm basically perplexed--it seems like there should be a way to do this.
0
 
LVL 7

Expert Comment

by:faster
ID: 1409726
we have the same problem.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 11

Expert Comment

by:alexo
ID: 1409727
Assuming you only have one tray (you *can* have more...)

HWND hw = FindWindow("Shell_TrayWnd", NULL);


0
 

Author Comment

by:danbind
ID: 1409728
Yes, this is true, and thanks for the help.  This is the answer to the question that I asked, but I guess I asked it wrong (see previous comments).  Restating, it is this:  How do you delete orphaned icons from the system tray, or force the system tray to validate them?  I would like to be able to split the points between galkin and alexo, as the answers are correct.  I would still like a solution to my problem (if one exists), however.
FYI, I found a posting in DejaNews by Jonathan Edwards showing how to find the number of icons in the tray, although I haven't tried it out.
0
 
LVL 1

Accepted Solution

by:
_Zaphod earned 400 total points
ID: 1409729
Windows deletes an orphaned icon if you put the cursor above it and wait for the Tip to come.
My guess is that if you emulate a click on the orphaned icon, Windows will understand its parent has died and will remove it. Use WM_CLICK, WM_LBUTTONDOWN or WM_LBUTTONUP, I guess, on the tray window (finding it as alexo told you), with the parameters pointing to the icon. Shouldn't be too hard.
0
 

Author Comment

by:danbind
ID: 1409730
I was hoping that there might be another way, as I'm never comfortable imitating user input--but this works well enough, so I guess you get the cigar.  Thanks!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question