0

我有一个出现在计时器上的无模式单例表单。

如果表单所属的应用程序是活动应用程序但表单不在顶部,我希望表单显示在应用程序的所有其他窗口的顶部。如果他们随后单击离开它以将其推到应用程序的其他窗口后面,则取决于用户。

如果表单所属的应用程序不是活动应用程序,那么我希望任务栏图标闪烁(这是有效的),并且我希望表单仅出现在该应用程序中的所有其他应用程序之上,因此当用户返回时对它来说,它是由他们来处理的。

我尝试过使用form.BringToFront()form.TopMost = true; form.TopMost = false;但这两种解决方案都将表单置于所有应用程序的顶部。如果他们在另一个程序中工作,我不想惹恼我的用户。

有没有办法实现我想要的?

表单激活函数:

    public static RemindersList CreateInstance(List<Reminder> rs)
    {
        if (_singleton == null)
        {
            _singleton = new RemindersList(rs);
            _singleton.Activate();
            _singleton.TopMost = true;
            _singleton.TopMost = false;
            // Flash in taskbar if not active window
            FlashWindow.Flash(_singleton);
            return _singleton;
        }
        else
        {
            _singleton.TopMost = true;
            _singleton.TopMost = false;
            // Flash in taskbar if not active window
            FlashWindow.Flash(_singleton);
            return null;
        }
    }
4

1 回答 1

0

使用 NotifyIcon 怎么样?

http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx

于 2014-08-12T06:28:17.313 回答