The
struct FlashWindowInfo
has value semantics, which means using
_with
is the problem, because it makes a
copy of
info
. Simplify to:
public static void FlashWindow(Form FormToFlash, FlashOptions Options, bool FlashIfFocused, uint FlashTimes = 5)
{
if (!FlashIfFocused && FormToFlash.ContainsFocus)
return;
FlashWindowInfo info = default(FlashWindowInfo);
info.cbSize = Marshal.SizeOf(info);
info.dwFlags = Convert.ToUInt32(Options);
info.dwTimeout = 0;
info.hwnd = FormToFlash.Handle;
info.uCount = FlashTimes;
FlashWindowEx(ref info);
}
You probably want to add
[StructLayout(LayoutKind.Sequential)]
to the
struct FlashWindowInfo
declaration.