Search code examples
c#winformsvisual-studio-2008notifyicon

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


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

Thanks


Solution

  • You can't. It isn't hard to get the window handle for the system tray, GetClassName() returns "ToolbarWindow32", the class name of the standard TOOLBAR common control. Beware that a 64-bit OS has two of them. Then you can send messages to it like TB_GETBUTTONINFO. Chief hang-ups are that you won't know what button ID to choose and the returned info does not include the button position.

    Which is for the better, buttons move around without you being able to lock them.