0

我搜索了论坛,但仍然没有答案似乎是正确的。

当用户在浏览器中操作时,我需要显示来自系统托盘应用程序的消息通知。

我希望此通知显示在所有内容之上,但即使我将其设置为 TopMost 或 TopLevel 或 BringToFront 或 Focus,我也无法实现我想要的。

我正在使用一个简单的 Windows 窗体,并使用系统托盘应用程序中的 ShowDialog 显示它。

请帮我 :)

PS:如果我从系统托盘应用程序启动通知表单而没有其他应用程序打开或聚焦它工作正常,我只是无法在活动浏览器窗口前显示它

4

2 回答 2

0
NameOfYourWindow myTopForm = new NameOfYourWindow();

myTopForm.Owner = App.Current.MainWindow;
myTopForm.ShowInTaskbar = false;
myTopForm.TopMost = true;
myTopForm.ShowDialog();
于 2014-01-21T14:52:49.520 回答
0
#region SetForegroundWindow
    [DllImport("kernel32.dll", ExactSpelling = true)]
    public static extern IntPtr GetConsoleWindow();
    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetForegroundWindow(IntPtr hWnd);
    #endregion
     static void Main(string[] args)
    {
        while (true)
        {

            SetForegroundWindow(GetConsoleWindow());
        }
    }
于 2015-10-31T21:24:59.053 回答