基于WebView2实现的Win11桌面框架,利用插件自定义
chunhualin1
2026-08-12 da97410f48a1e94d7e1fe019c69a7c847fe67ddf
src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
@@ -1,3 +1,4 @@
using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Layout;
@@ -17,16 +18,22 @@
    public bool IsSupported() => true;
    public bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error)
    public bool TryAttachDesktopWindow(IntPtr hwnd, MonitorInfo monitor, RectD bounds, out string? error)
    {
        error = null;
        var scale = monitor.Scale;
        var x = (int)(bounds.X * scale);
        var y = (int)(bounds.Y * scale);
        var w = (int)(bounds.Width * scale);
        var h = (int)(bounds.Height * scale);
        if (!NativeMethods.SetWindowPos(
            hwnd,
            NativeMethods.HwndBottom,
            (int)bounds.X,
            (int)bounds.Y,
            (int)bounds.Width,
            (int)bounds.Height,
            x,
            y,
            w,
            h,
            NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
        {
            error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";