From 97df0fb5ed49e37d1c8e0e62057bb72ba5c9eb6a Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期三, 12 八月 2026 17:24:49 +0800
Subject: [PATCH] 优化透明样式

---
 src/Moli.Desktop/Interop/NativeMethods.cs |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/Moli.Desktop/Interop/NativeMethods.cs b/src/Moli.Desktop/Interop/NativeMethods.cs
index 2922088..d3fa8d1 100644
--- a/src/Moli.Desktop/Interop/NativeMethods.cs
+++ b/src/Moli.Desktop/Interop/NativeMethods.cs
@@ -6,19 +6,28 @@
 
 internal static class NativeMethods
 {
+    internal const int GwlStyle = -16;
     internal const int GwlExStyle = -20;
+    internal const uint WsChild = 0x40000000;
+    internal const uint WsPopup = 0x80000000;
+    internal const uint WsVisible = 0x10000000;
     internal const int WsExTransparent = 0x00000020;
     internal const int WsExLayered = 0x00080000;
     internal const int WsExToolWindow = 0x00000080;
     internal const int WsExNoActivate = 0x08000000;
-    internal const int LwaAlpha = 0x00000002;
     internal const uint SwpNoSize = 0x0001;
     internal const uint SwpNoMove = 0x0002;
     internal const uint SwpNoZOrder = 0x0004;
     internal const uint SwpNoActivate = 0x0010;
+    internal const uint SwpFrameChanged = 0x0020;
     internal const uint SwpShowWindow = 0x0040;
     internal const uint SmtoNormal = 0x0000;
+    internal const int WmDisplayChange = 0x007E;
+    internal const int WmSettingChange = 0x001A;
+    internal const int WmDeviceChange = 0x0219;
+    internal const int MdtEffectiveDpi = 0;
     internal static readonly IntPtr HwndBottom = new(1);
+    internal static readonly IntPtr HwndMessage = new(-3);
 
     internal delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
     internal delegate bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData);
@@ -34,10 +43,6 @@
 
     [DllImport("user32.dll", EntryPoint = "SetWindowLongW", SetLastError = true)]
     internal static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong);
-
-    [DllImport("user32.dll", SetLastError = true)]
-    [return: MarshalAs(UnmanagedType.Bool)]
-    internal static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
 
     [DllImport("user32.dll", SetLastError = true)]
     [return: MarshalAs(UnmanagedType.Bool)]
@@ -67,6 +72,17 @@
     [return: MarshalAs(UnmanagedType.Bool)]
     internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref MonitorInfoEx lpmi);
 
+    [DllImport("shcore.dll", SetLastError = false)]
+    internal static extern int GetDpiForMonitor(IntPtr hMonitor, int dpiType, out uint dpiX, out uint dpiY);
+
+    [DllImport("user32.dll", SetLastError = true)]
+    [return: MarshalAs(UnmanagedType.Bool)]
+    internal static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect);
+
+    [DllImport("user32.dll", SetLastError = false)]
+    [return: MarshalAs(UnmanagedType.Bool)]
+    internal static extern bool IsWindow(IntPtr hWnd);
+
     internal static IntPtr GetWindowLongPtr(IntPtr hwnd, int index)
     {
         return IntPtr.Size == 8

--
Gitblit v1.9.1