59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System.CodeDom.Compiler;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace LLib.ImGui;
|
|
|
|
public static class WindowFlash
|
|
{
|
|
private struct FLASHWINFO
|
|
{
|
|
public uint cbSize;
|
|
|
|
public nint hwnd;
|
|
|
|
public uint dwFlags;
|
|
|
|
public uint uCount;
|
|
|
|
public uint dwTimeout;
|
|
}
|
|
|
|
private const uint FLASHW_ALL = 3u;
|
|
|
|
private const uint FLASHW_TIMERNOFG = 12u;
|
|
|
|
[LibraryImport("user32.dll")]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
|
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "10.0.14.37416")]
|
|
[SkipLocalsInit]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
private unsafe static bool FlashWindowEx(ref FLASHWINFO pwfi)
|
|
{
|
|
int num;
|
|
fixed (FLASHWINFO* _pwfi_native = &pwfi)
|
|
{
|
|
num = __PInvoke(_pwfi_native);
|
|
}
|
|
return num != 0;
|
|
[DllImport("user32.dll", EntryPoint = "FlashWindowEx", ExactSpelling = true)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
|
static extern unsafe int __PInvoke(FLASHWINFO* __pwfi_native);
|
|
}
|
|
|
|
public static void Flash(nint hwnd, uint count = 3u)
|
|
{
|
|
if (hwnd != 0)
|
|
{
|
|
FLASHWINFO pwfi = new FLASHWINFO
|
|
{
|
|
cbSize = (uint)Marshal.SizeOf<FLASHWINFO>(),
|
|
hwnd = hwnd,
|
|
dwFlags = ((count == 0) ? 15u : 3u),
|
|
uCount = count,
|
|
dwTimeout = 0u
|
|
};
|
|
FlashWindowEx(ref pwfi);
|
|
}
|
|
}
|
|
}
|