diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 3ebcd65c7..01661678b 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -108,7 +108,12 @@ namespace Flow.Launcher.Core.Resource public void RefreshFrame() { IntPtr mainWindowPtr = new WindowInteropHelper(mainWindow).Handle; + if (mainWindowPtr == IntPtr.Zero) + return; + HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr); + if (mainWindowSrc == null) + return; //mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 255, 181, 178); ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS(); @@ -136,7 +141,12 @@ namespace Flow.Launcher.Core.Resource //SetWindowAccent(); var dict = GetThemeResourceDictionary(Settings.Theme); + if (dict == null) + return; + var windowBorderStyle = dict["WindowBorderStyle"] as Style; + if (windowBorderStyle == null) + return; Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); if (BlurEnabled) { diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 8270150c2..264f57cb5 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -181,7 +181,10 @@ namespace Flow.Launcher private void OnLoaded(object sender, RoutedEventArgs _) { - ThemeManager.Instance.RefreshFrame(); + Dispatcher.BeginInvoke((Action)(() => + { + ThemeManager.Instance.RefreshFrame(); + }), DispatcherPriority.Background); // MouseEventHandler PreviewMouseMove += MainPreviewMouseMove;