improve:窗口无焦点

This commit is contained in:
2025-07-20 21:03:42 +08:00
parent ba6303dca0
commit 476503338f
+9 -5
View File
@@ -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) {