Flash Form window

Flash window to alert user or attract attention

        static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);

        public struct FLASHWINFO
            public UInt32 cbSize;
            public IntPtr hwnd;
            public Int32 dwFlags;
            public UInt32 uCount;
            public Int32 dwTimeout;
        // stop flashing
        Int32 FLASHW_STOP = 0;

        // flash the window title
        Int32 FLASHW_CAPTION = 1;

        // flash the taskbar button
        Int32 FLASHW_TRAY = 2;

        // 1 | 2
        Int32 FLASHW_ALL = 3;

        // flash continuously
        Int32 FLASHW_TIMER = 4;

        // flash until the window comes to the foreground
        Int32 FLASHW_TIMERNOFG = 12;

        public void Flash()
            FLASHWINFO fw = new FLASHWINFO();

            fw.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO)));
            fw.hwnd = this.Handle;
            fw.dwFlags = FLASHW_ALL;
            fw.uCount = UInt32.MaxValue;

            FlashWindowEx(ref fw);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s