30 January 2007
Windows Forms - FlashWindowEx implementation
Posted by Mikhail Esteves under: C#; Tips .
A nice way to alert your users when your Windows Forms application is not active, and a certain task is complete.
public enum FLASHWINFOFLAGS { FLASHW_STOP = 0, FLASHW_CAPTION = 0x00000001, FLASHW_TRAY = 0x00000002, FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY), FLASHW_TIMER = 0x00000004, FLASHW_TIMERNOFG = 0x0000000C }[StructLayout(LayoutKind.Sequential)] public struct FLASHWINFO { public UInt32 cbSize; public IntPtr hwnd; public Int32 dwFlags; public UInt32 uCount; public Int32 dwTimeout; }[DllImport("user32.dll")] public static extern int FlashWindowEx(ref FLASHWINFO pfwi);// Example use private void dBrowser_DocumentCompleted( object sender, WebBrowserDocumentCompletedEventArgs e) { if (!IsActive) { // Flash the window FLASHWINFO fwi = new FLASHWINFO(); fwi.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))); fwi.hwnd = this.Handle; fwi.dwFlags = (Int32) (FLASHWINFOFLAGS.FLASHW_ALL | FLASHWINFOFLAGS.FLASHW_TIMERNOFG); fwi.dwTimeout = 0;FlashWindowEx(ref fwi); } }
windows+forms, winforms, c#, csharp, flashwindow, flashwindowex, win32