我偶然发现了下面的代码,并尝试在我的WinForm应用程序中实现它,以帮助那些不太懂技术的用户。
不幸的是,它什么都没做。它既没有生成任何错误,也没有闪烁。能否有人提供任何见解?我已经在Win 7(x64)和Win XP(x86)上尝试过,结果都相同。
我像这样调用它 --> TaskbarFlasher.FlashWindow(this); 从我的主窗体。
不幸的是,它什么都没做。它既没有生成任何错误,也没有闪烁。能否有人提供任何见解?我已经在Win 7(x64)和Win XP(x86)上尝试过,结果都相同。
我像这样调用它 --> TaskbarFlasher.FlashWindow(this); 从我的主窗体。
[DllImport("user32.dll")]
private extern static bool FlashWindow(IntPtr hwnd, bool bInvert);
[DllImport("user32.dll")]
private extern static IntPtr GetForegroundWindow();
/// <summary>
/// Notifies the user that the application requests attention
/// by flashing the taskbar if the form is not the current window.
/// </summary>
/// <param name="myForm">The form in question.</param>
public static void FlashWindow(Form myForm)
{
// if the current foreground window isn't this window,
// flash this window in task bar once every 1 second
if (GetForegroundWindow() != myForm.Handle)
{
FlashWindow(myForm.Handle, true);
}
}