From e272112440984d183bb6193cb1389b6b47934eda Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:33:54 -0400 Subject: [PATCH] Correctly use ref parameters when flashing taskbar icon (#1236) --- TwitchDownloaderWPF/MainWindow.xaml.cs | 4 ++-- TwitchDownloaderWPF/Services/NativeFunctions.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TwitchDownloaderWPF/MainWindow.xaml.cs b/TwitchDownloaderWPF/MainWindow.xaml.cs index 05876f92..a6d40d01 100644 --- a/TwitchDownloaderWPF/MainWindow.xaml.cs +++ b/TwitchDownloaderWPF/MainWindow.xaml.cs @@ -153,7 +153,7 @@ private async void FlashTaskbarIconIfNotForeground(TimeSpan flashDuration) FlashCount = uint.MaxValue, Timeout = 0 }; - _ = NativeFunctions.FlashWindowEx(flashWInfo); + _ = NativeFunctions.FlashWindowEx(ref flashWInfo); await Task.Delay(flashDuration); @@ -165,7 +165,7 @@ private async void FlashTaskbarIconIfNotForeground(TimeSpan flashDuration) FlashCount = 0, Timeout = 0 }; - _ = NativeFunctions.FlashWindowEx(stopFlashWInfo); + _ = NativeFunctions.FlashWindowEx(ref stopFlashWInfo); } private class FfmpegDownloadProgress : IProgress diff --git a/TwitchDownloaderWPF/Services/NativeFunctions.cs b/TwitchDownloaderWPF/Services/NativeFunctions.cs index aa788fc4..9bda74c0 100644 --- a/TwitchDownloaderWPF/Services/NativeFunctions.cs +++ b/TwitchDownloaderWPF/Services/NativeFunctions.cs @@ -15,7 +15,7 @@ public static unsafe class NativeFunctions [DllImport("user32.dll", EntryPoint = "FlashWindowEx", PreserveSig = true)] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool FlashWindowEx(FlashWInfo info); + public static extern bool FlashWindowEx([In] ref FlashWInfo info); // https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-flashwinfo [StructLayout(LayoutKind.Sequential)]