在系统托盘图标上方显示一个窗口

时间:2017-04-27 22:34:33

标签: c# wpf winforms

我为wpf应用程序制作了一个系统托盘图标:

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;

单击图标托盘时打开的窗口

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();
    }
}

我将Window启动位置设置为工作区域 - 窗口大小:

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

然而,有两个屏幕,窗口打开:

location1

更改为:

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

窗口出现在这里:

location2

有没有办法获取系统托盘图标的桌面位置并在其上方生成窗口?还是有不同的方法来设置我错过的位置?

有关查找系统图标位置的问题并不起作用。我希望实现与动作中心或音量控制相同的功能:

location3

这是一个直接显示在系统图标上方的窗口。

0 个答案:

没有答案