0

I have made a system tray icon for a wpf application:

PopWindow popm = new PopWindow();
this.nIcon.Icon = new System.Drawing.Icon(@"../../Resources/MyIcon.ico");
this.nIcon.Visible = true;
this.nIcon.ShowBalloonTip(5000, "COZSim", "The COZSim run has completed click here to open", ToolTipIcon.Info);
this.nIcon.Click += NIcon_Click;
this.nIcon.BalloonTipClicked += NIcon_BalloonTipClicked;

And the window that opens when the icon tray is clicked

PopWindow popm = new PopWindow();
private void NIcon_Click(object sender, EventArgs e)
{
    if (!popm.IsActive)
    {
        popm.Owner = this;
        var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
        popm.WindowStartupLocation = WindowStartupLocation.Manual;
        popm.Topmost = true;
        popm.Top = desktopWorkingArea.Bottom - popm.ActualHeight;
        popm.Left = desktopWorkingArea.Right - popm.ActualWidth;
        popm.ResizeMode = ResizeMode.NoResize;
        popm.Show();
    }
}

I set the Window start up location as the work area - the size of the window:

popm.Top = desktopWorkingArea.Bottom - popm.ActualHeight;
popm.Left = desktopWorkingArea.Right - popm.ActualWidth;

However with two screens the window opens here:

location1

When changing to:

popm.Top = desktopWorkingArea.Bottom - popm.Height;
popm.Left = desktopWorkingArea.Right - popm.Width;

The window appears here:

location2

Is there a way to get the desktop location of the system tray icon and spawn the window above it? or is there a different method of setting the location I have completley missed?

The question about finding the location of the system icon doesn't help. I am looking to implement functionality like with the action centre or volume control:

location3

Which is a window that appears directly above the system icon.

Community
  • 1
  • 1
Jack Miller
  • 325
  • 1
  • 16
  • Possible duplicate of [How to find the location of the icon in the system tray](http://stackoverflow.com/questions/272778/how-to-find-the-location-of-the-icon-in-the-system-tray) – Rufus L Apr 27 '17 at 22:40
  • 1
    Sort of, but that doesn't give me an answer. I want to spawn the window above the system icon. I will add an example above – Jack Miller Apr 27 '17 at 22:51
  • You mean the second answer to that question (with 3 upvotes) doesn't work? – Rufus L Apr 27 '17 at 22:53
  • Sorry, I checked the accepted answer. will have a look now – Jack Miller Apr 27 '17 at 22:57
  • BE AWARE OF, that some guys may have the taskbar at the top or the left or at the right position of the window.... – SiL3NC3 Jan 12 '23 at 09:12

0 Answers0