Link to home
Start Free TrialLog in
Avatar of Traal
Traal

asked on

Balloon hint for notification area icon

I have a program that minimizes to the notification area (i.e. "system tray"), and when it gets minimized I want to display a balloon hint with the balloon stem coming up from the icon in the tray.  I imagine that if I could use the Windows API to do it, it would position itself automatically.  As I haven't been able to figure out how to use the API to do it, I'm currently using the JEDI BalloonHint control and positioning it with:

          Handle1 := FindWindow('Shell_TrayWnd', Nil);
          Handle2 := FindWindowEx(Handle1, 0, 'TrayNotifyWnd', '');
          Handle3 := FindWindowEx(Handle2, 0, 'SysPager', '');
          GetWindowRect(Handle3, WindowRect);
          ScreenCoords := ScreenToClient(WindowRect.TopLeft);

This A) only gets me the coordinates of the tray and not an icon in it; and B) is rather inelegant in any case.  I would much prefer to use the Windows API to do it.  So, then, the question is:  how can I popup a balloon hint over a particular icon in the tray?

Brian
Avatar of 2266180
2266180
Flag of United States of America image

well, I would use CoolTrayIcon for all that :) (http://subsimple.com/delphi.asp)
I didn't find a nicer way of getting the coordinates of a tray icon.
Avatar of Traal
Traal

ASKER

I try not to just throw a new component at a problem, when I can learn something from coding it myself.  I am handling all of the "tray" coding programmatically; no fancy components here.  I'd prefer to keep it that way, if possible.  What I'm looking for is identical to what the "Safely Remove Hardware" dialog pops up when you stop a USB device (i.e. "Safe To Remove Hardware" message).

Brian
well, usually, the baloon tips/hints are shown by the owner of teh tray icon which knows the handle of the icon so it can easily find the coordinates.
I can't think of another way os getting teh coordinates of teh tray icon since windwos will usually hide some and show some so the coordinates change.

but if you want to show the baloon for your icon only, then just use the handle from the TNotifyIconData structure directly to find the coordinates.
ASKER CERTIFIED SOLUTION
Avatar of alkisg
alkisg
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also have a look at this example:
http://www.swissdelphicenter.ch/en/showcode.php?id=1164
SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial