我正在開發一個控制機器的應用程序。
當我從機器收到錯誤時,用戶應該能夠直接注意到它,一種方法是在任務欄上閃爍托盤。當機器清除錯誤時,紙盤應停止閃爍。使用FlashWindowEx函數有一點煩惱,當我清除窗口的閃爍時,它保持(在我的情況下是winXP)橙色(不閃爍)。
FlashWindowEx FLASHW_STOP仍然保持任務欄有顏色
[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的一個已知錯誤,是否有修復?
給你的答案添加一些解釋。 – Sandeep 2016-04-20 10:14:06