我正在开发一个控制机器的应用程序.
当我从机器收到错误时,用户应该能够直接注意到它,一种方法是在任务栏上闪烁托盘.当机器清除错误时,托盘应停止闪烁.
使用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;
}
Run Code Online (Sandbox Code Playgroud)
在我的情况下,我使用FLASHW_TRAY开始闪烁,使用FLASHW_STOP来停止闪烁.
我做错了什么或者这是WinXP的已知错误并且有解决方法吗?
当窗口按照预期的时间完成闪烁时,行为是相同的:任务栏按钮保持彩色。我不认为这是一个错误。如果你想一想,当你使用 时FLASHW_STOP,闪烁实际上确实停止了,但闪烁的目的是为了引起用户的注意。该按钮保持彩色,因为用户可能仍然没有低头并发现哪个窗口试图引起她的注意。保持按钮颜色可以保持该信息可用。
| 归档时间: |
|
| 查看次数: |
2777 次 |
| 最近记录: |