Hi Ben,
Thanks for choosing MSDN Newsgroup!
My name is Ying Shen Yu, I'll be assist you on this issue.
From your description, my understanding to your question now is you
application shows an notify icon in the tray area, when the program popup
some info, you'd like to pop up a customized form instead of the ballon tip
and set the position just beside the notify icon.
Based on my research, there is no official APIs to get exact location of
the notify icon. However, you can get the position of the "notification
area" window instead by P/Invoke.
Then maybe we can show the customize window beside the notification area
as a workaround.
Through Spy++, we can see the caption of the tray icon area is
"Notification Area".
So we may use API FindWindow to get the window handle, then API
GetWindowRect should give you postion of the window in screen coordinates.
Here is a simple sample snippet just to clarify my idea:
<code>
[DllImport("user32.dll")]
public extern static IntPtr FindWindowEx(IntPtr parentWnd, IntPtr
childAfter, string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
public extern static int GetWindowRect(IntPtr hWnd,out Rect lpRect);
private void button1_Click(object sender, System.EventArgs e)
{
Rect rc;
IntPtr hwnd = FindWindowEx(IntPtr.Zero,IntPtr.Zero,"Shell_TrayWnd",null);
hwnd = FindWindowEx(hwnd , IntPtr.Zero ,"TrayNotifyWnd",null);
hwnd = FindWindowEx(hwnd , IntPtr.Zero ,"SysPager",null);
if (hwnd != IntPtr.Zero)
{
hwnd = FindWindowEx(hwnd , IntPtr.Zero ,null,"Notification Area");
if (hwnd != IntPtr.Zero)
{
if ( GetWindowRect(hwnd,out rc) != 0)
{
System.Console.WriteLine(rc);
}
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
public override string ToString()
{
return "Left: " + left.ToString() + " Top: " +
top.ToString() + " Right: " + right.ToString() + "Bottom: " +
bottom.ToString();
}
}
</code>
If you have any further question on this issue, please feel free to reply
this thread.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.