Solved

Repainting system tray

Posted on 1997-12-30
7
553 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using an Atomic update intermittently results in duplicates 14 36
SSRS troubles 4 104
Please explain the parts of these 2 LINQ expressions 3 102
C# LINQ ForEach() question 6 114
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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