我正在开发一个控制机器的应用程序。
当我从机器收到错误时,用户应该能够直接注意到它,一种方法是在任务栏上闪烁托盘。当机器清除错误时,托盘应停止闪烁。
使用 FlashWindowEx 函数有一点点烦恼,当我清除窗口的闪烁时,它会保持(在我的情况下为 winXP)橙色(不闪烁)。
[Flags]
public enum FlashMode {
///
/// Stop flashing. The system restores the window to its original state.
///
FLASHW_STOP = 0,
///
/// Flash the window caption.
///
FLASHW_CAPTION = 1,
///
/// Flash the taskbar button.
///
FLASHW_TRAY = 2,
///
/// Flash both the window caption and taskbar button.
/// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
///
FLASHW_ALL = 3,
///
/// Flash continuously, until the FLASHW_STOP flag is set.
///
FLASHW_TIMER = 4,
///
/// Flash continuously until the window comes to the foreground.
///
FLASHW_TIMERNOFG = 12
}
public static bool FlashWindowEx(IntPtr hWnd, FlashMode fm) {
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = hWnd;
fInfo.dwFlags = (UInt32)fm;
fInfo.uCount = UInt32.MaxValue;
fInfo.dwTimeout = 0;
return FlashWindowEx(ref fInfo);
}
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO {
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
就我而言,我使用 FLASHW_TRAY 开始闪烁并使用 FLASHW_STOP 停止闪烁。
我做错了什么还是这是 WinXP 的一个已知错误,是否有解决方法?