How to find the location of the icon in the system tray

I have a NotifyIcon control that appears in the system tray. How to find the location (x, y) of an icon on the screen?

thanks

+3
source share
3 answers

You can not. It is easy to get a window handle for the system tray, GetClassName () returns "ToolbarWindow32", the class name of the standard TOOLBAR control. Remember that a 64-bit OS has two of them. You can then send him messages like TB_GETBUTTONINFO. The main hang is that you will not know which button identifier to select, and the returned information does not include the button position.

For the better, the buttons move without the ability to lock.

+1
source

You can actually do this, here is a code that shows you, like so much more.

In any mouse event from NotifyIcon, just look at Control.MousePosition, this contains (x, y) mice. The same can be done to position ContextMenu in the form / control exactly where the form / control was clicked using these values ​​(x, y).

A good example of both of them is here:

More details here: http://code.msdn.microsoft.com/TheNotifyIconExample

+4
source

After a long journey of trial and error, as well as developing my own badge identifier, I devised a way to find the best position badge, so good, until I saw this amazing project by @zhwang SuperNotifyIcon . This project has three ways to find the notification icon, starting from inaccurate (for example, my own development) and ending with using the new in the Windows 7 API. This is the final answer.

+2
source

All Articles