forked from Rampastring/Rampastring.Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowFlasher.cs
53 lines (45 loc) · 1.56 KB
/
WindowFlasher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#if false
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Rampastring.Tools
{
public static class WindowFlasher
{
// To support flashing.
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
//Flash both the window caption and taskbar button.
//This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
public const uint FLASHW_ALL = 3;
// Flash continuously until the window comes to the foreground.
public const uint FLASHW_TIMERNOFG = 12;
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public uint cbSize;
public IntPtr hwnd;
public uint dwFlags;
public uint uCount;
public uint dwTimeout;
}
/// <summary>
/// Flashes a form's window in the taskbar.
/// </summary>
/// <param name="form">The form to flash.</param>
/// <returns>The return value fo FlashWindowEx.</returns>
public static bool FlashWindowEx(Form form)
{
IntPtr hWnd = form.Handle;
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = hWnd;
fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
fInfo.uCount = UInt32.MaxValue;
fInfo.dwTimeout = 0;
return FlashWindowEx(ref fInfo);
}
}
}
#endif