From 476503338f5363324173f4dc5b692b2820996d14 Mon Sep 17 00:00:00 2001 From: unknown <2564608840@qq.com> Date: Sun, 20 Jul 2025 21:03:42 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E7=AA=97=E5=8F=A3=E6=97=A0=E7=84=A6?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow.xaml.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 7171b72f..fd1a73bb 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -133,6 +133,15 @@ namespace Ink_Canvas { ShowPage(currentPageIndex); } + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + // 设置窗口为无焦点(不会抢占焦点) + var hwnd = new WindowInteropHelper(this).Handle; + int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_NOACTIVATE); + } + #endregion #region Ink Canvas Functions @@ -318,11 +327,6 @@ namespace Ink_Canvas { // 初始化插件系统 InitializePluginSystem(); - - // 设置窗口为无焦点(不会抢占焦点) - var hwnd = new WindowInteropHelper(this).Handle; - int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE); - SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_NOACTIVATE); } private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e) {