728x90
/// <summary>
/// FlashWindow
/// </summary>
public partial class FlashWindow : Form
{
    public const int FLASHW_STOP = 0;
    public const int FLASHW_ALL = 3;

 

    [StructLayout(LayoutKind.Sequential)]
    public struct FLASHWINFO
    {
        public int cbSize;
        public IntPtr hwnd;
        public int dwFlags;
        public int uCount;
        public int dwTimeout;
    }

 

    [DllImport("user32.dll")]
    static extern bool FlashWindowEx(ref FLASHWINFO pwfi);

 

    protected override void OnActivated(EventArgs e)
    {
        base.OnActivated(e);
        Flash(false);
    }

 

    protected override void OnSizeChanged(EventArgs e)
    {
        base.OnSizeChanged(e);

        if(this.WindowState == FormWindowState.Minimized)
            Flash(true);
    }

    private void Flash(bool flashed)
    {
        FLASHWINFO fi = new FLASHWINFO();
        fi.cbSize = Marshal.SizeOf(typeof(FLASHWINFO));
        fi.hwnd = this.Handle;
        fi.dwFlags = flashed ? FLASHW_ALL : FLASHW_STOP;
        fi.uCount = 10;
        fi.dwTimeout = 500;

        FlashWindowEx(ref fi);
    }
}

728x90
Posted by kjun.kr
,