Shell_notifyicongetrect [verified]

Beyond the Balloon: Using Shell_NotifyIconGetRect to Find Your Notify Icon’s Exact Screen Location

Shell_NotifyIconGetRect is . Windows knows exactly where it drew your icon; this API simply returns that truth.

The Shell_NotifyIconGetRect function is used to retrieve the position and size of a notification icon in the notification area. This information can be useful for positioning other windows or controls in relation to the icon. shell_notifyicongetrect

HRESULT Shell_NotifyIconGetRect( [in] const NOTIFYICONIDENTIFIER *identifier, [out] RECT *iconRect );

BOOL Shell_NotifyIconGetRect( NOTIFYICONDATA *pnid, RECT *prc ); This information can be useful for positioning other

This made common UI tasks surprisingly difficult:

// Helper function to draw a rectangle on the screen (overlay) void VisualizeRect(RECT rc, COLORREF color, int durationMs) // Create a window to draw on (topmost, layered for transparency) HWND hDesktop = GetDesktopWindow(); HDC hdc = GetDCEx(hDesktop, NULL, DCX_CACHE [out] RECT *iconRect )

Gets the screen coordinates of the bounding rectangle of a notification icon. Microsoft Learn Using the Shell_NotifyIconGetRect function for TTrayIcon