When your notification icon receives the message corresponding to an action, you can query at that point to find out an associated point on the screen.
For example if you are handling WM_RBUTTONUP
, WM_CONTEXTMENU
etc. in your icon's message procedure you can call GetMessagePos
to find out the position on the icon associated with the message.
I wrap this up with the following function so that I can decode the message into a TPoint
:
function MessagePoint: TPoint;
begin
Result := TSmallPoint(GetMessagePos());
end;
So what you can do is, in your icon's message procedure, make a note of this point. When you need to show the form, use this point to determine where your icon lives. Since the point can be in the taskbar, you'll need to clip it into the work area.
After your question update it seems you want to know how to find out the location of the taskbar. Do that by calling SHAppBarMessage
passing ABM_GETTASKBARPOS
.