C# 闪光外窗
如何刷新外部应用程序的任务栏图标?我已经尝试过FlashWindowEx,并在Pinvoke.net上进行了检查,但这只涉及到当前表单的刷新(这个)。但我不能让它在外部窗口闪烁C# 闪光外窗,c#,.net,winforms,C#,.net,Winforms,如何刷新外部应用程序的任务栏图标?我已经尝试过FlashWindowEx,并在Pinvoke.net上进行了检查,但这只涉及到当前表单的刷新(这个)。但我不能让它在外部窗口闪烁 我有一个hWnd(IntPtr)和一个process.MainWindowHandle指向我要刷新的外部应用程序,但我不知道如何使用FlashWindowEx来刷新外部窗口。当您调用FlashWindowEx时,只需传递要刷新的其他应用程序的MainWindowHandle即可。例如,您可以使用下面显示的FlashOth
我有一个hWnd(IntPtr)和一个process.MainWindowHandle指向我要刷新的外部应用程序,但我不知道如何使用FlashWindowEx来刷新外部窗口。当您调用
FlashWindowEx
时,只需传递要刷新的其他应用程序的MainWindowHandle即可。例如,您可以使用下面显示的FlashOtherWindow
函数传递句柄
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
internal static void FlashOtherWindow(IntPtr windowHandle)
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.dwFlags = 2;
fInfo.dwTimeout = 0;
fInfo.hwnd = windowHandle;
fInfo.uCount = 3;
FlashWindowEx(ref fInfo);
}
internal static void FlashApplicationWindow(string application)
{
foreach (Process process in Process.GetProcessesByName(application))
FlashOtherWindow(process.MainWindowHandle);
}
我还包括了采用应用程序名称的FlashApplicationWindow
。您可以这样使用它:
FlashApplicationWindow("firefox");
调用
FlashWindowEx
时,只需传递要闪存的其他应用程序的MainWindowHandle。例如,您可以使用下面显示的FlashOtherWindow
函数传递句柄
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
internal static void FlashOtherWindow(IntPtr windowHandle)
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.dwFlags = 2;
fInfo.dwTimeout = 0;
fInfo.hwnd = windowHandle;
fInfo.uCount = 3;
FlashWindowEx(ref fInfo);
}
internal static void FlashApplicationWindow(string application)
{
foreach (Process process in Process.GetProcessesByName(application))
FlashOtherWindow(process.MainWindowHandle);
}
我还包括了采用应用程序名称的FlashApplicationWindow
。您可以这样使用它:
FlashApplicationWindow("firefox");