From 338c048182e142b02c7e69f19775ec0bb1f5d87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=80=89=E8=87=A3?= Date: Fri, 14 Aug 2026 01:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=B8=AA=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=89=B2=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WinFormedge/Classes.Formedge/FormBase.cs | 6 +++--- src/WinFormedge/Classes.Formedge/Formedge.Internal.cs | 11 ++++++----- src/WinFormedge/Classes.WebView/WebViewCore.cs | 4 ++-- src/WinFormedge/WinFormedge.csproj | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/WinFormedge/Classes.Formedge/FormBase.cs b/src/WinFormedge/Classes.Formedge/FormBase.cs index 3d907ac..28224a4 100644 --- a/src/WinFormedge/Classes.Formedge/FormBase.cs +++ b/src/WinFormedge/Classes.Formedge/FormBase.cs @@ -1,4 +1,4 @@ -// This file is part of the WinFormedge project. +// This file is part of the WinFormedge project. // Copyright (c) 2025 Xuanchen Lin all rights reserved. // This project is licensed under the MIT License. // See the LICENSE file in the project root for more information. @@ -384,8 +384,8 @@ protected override void WndProc(ref Message m) } break; - case WM_ERASEBKGND: - return; + //case WM_ERASEBKGND when SystemBackdropType != SystemBackdropType.Auto: + // return; case WM_NCCALCSIZE when wParam == 1 && ExtendsContentIntoTitleBar && !Popup && !Fullscreen: { diff --git a/src/WinFormedge/Classes.Formedge/Formedge.Internal.cs b/src/WinFormedge/Classes.Formedge/Formedge.Internal.cs index c1746ce..2e9348a 100644 --- a/src/WinFormedge/Classes.Formedge/Formedge.Internal.cs +++ b/src/WinFormedge/Classes.Formedge/Formedge.Internal.cs @@ -1,4 +1,4 @@ -// This file is part of the WinFormedge project. +// This file is part of the WinFormedge project. // Copyright (c) 2025 Xuanchen Lin all rights reserved. // This project is licensed under the MIT License. // See the LICENSE file in the project root for more information. @@ -73,12 +73,14 @@ internal WebViewCore WebView { ProfileName = ProfileName, IsInPrivateMode = IsInPrivateMode, + }; - WebView.WebViewCreated += (_, _) => WebViewCreatedCore(); + WebView.WebViewCreated += (_, _) => WebViewCreatedCore(WindowStyleSettings); WindowStyleSettings.WndProc += WebView.HostWndProc; + } return _webViewCore; @@ -804,7 +806,7 @@ private void RegisterHostWindowEvents() /// /// Called when the WebView2 browser is created. Sets up host objects, scripts, and event handlers. /// - private void WebViewCreatedCore() + private void WebViewCreatedCore(WindowSettings windowStyleSettings) { if (WebView.Browser == null) throw new InvalidOperationException(); @@ -813,10 +815,9 @@ private void WebViewCreatedCore() var controller = WebView.Controller; var webview = WebView.Browser; - controller.DefaultBackgroundColor = Color.Transparent; + controller.DefaultBackgroundColor = windowStyleSettings.BackColor; WebView.ConfigureSettings += ConfigureWebView2Settings; - //WebView.ConfigureProfile += ConfigureWebView2Profile; controller.GotFocus += OnGotFocus; controller.LostFocus += OnLostFocus; diff --git a/src/WinFormedge/Classes.WebView/WebViewCore.cs b/src/WinFormedge/Classes.WebView/WebViewCore.cs index bc77ab1..87aac6d 100644 --- a/src/WinFormedge/Classes.WebView/WebViewCore.cs +++ b/src/WinFormedge/Classes.WebView/WebViewCore.cs @@ -1,4 +1,4 @@ -// This file is part of the WinFormedge project. +// This file is part of the WinFormedge project. // Copyright (c) 2025 Xuanchen Lin all rights reserved. // This project is licensed under the MIT License. // See the LICENSE file in the project root for more information. @@ -249,7 +249,7 @@ private async Task CreateWebView2Async() controller.ShouldDetectMonitorScaleChanges = true; controller.Bounds = Container.ClientRectangle; - controller.DefaultBackgroundColor = Color.Transparent; + controller.DefaultBackgroundColor = Container.BackColor; //Color.Transparent; var webview = controller!.CoreWebView2; diff --git a/src/WinFormedge/WinFormedge.csproj b/src/WinFormedge/WinFormedge.csproj index 117d4cb..fb0418d 100644 --- a/src/WinFormedge/WinFormedge.csproj +++ b/src/WinFormedge/WinFormedge.csproj @@ -60,7 +60,7 @@ - 1.1.2 + 1.1.3 True