/// 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);
}
}
'C# > Winform' 카테고리의 다른 글
(.NET) 다른 config 파일 읽어오기 (0) | 2017.04.15 |
---|---|
(.NET) List<T> To Table (0) | 2017.04.15 |
(.NET) 시작프로그램에 등록하기 (0) | 2017.04.15 |
(.NET) Control 에서 특정 메서드 호출하기 (0) | 2017.04.15 |
(.NET) PrimaryKey 기준 Table Merge 하기 (0) | 2017.04.15 |