HandyControl icon indicating copy to clipboard operation
HandyControl copied to clipboard

hc:Window在全屏显示时,占据面积超出了整个显示器,在双屏时可复现

Open LickBag opened this issue 1 year ago • 3 comments

Describe the bug

hc:Window在全屏显示时,占据面积超出了整个显示器,在双屏时可复现。 如下图,左边是HandyControlDemo全屏显示且激活在前方;右侧窗口是Everything最大化窗口未激活。 比较明显的看到HandyControlDemo的关闭按钮右侧还有东西,挡住了Everything窗口 MaxModeError

Steps to reproduce the bug

打开基于hc:Windows的窗口,最大化在左侧显示器,观察右侧显示

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.4.0

IDE

No response

Framework type

No response

Windows version

No response

Additional context

No response

LickBag avatar Sep 12 '24 06:09 LickBag

调试模式下是这样的,发布出来的exe就没问题了。你可以试试,我是vs2022,.net 8

imoonstal avatar Nov 12 '24 11:11 imoonstal

调试模式下是这样的,发布出来的exe就没问题了。你可以试试,我是vs2022,.net 8

bro release模式下也是这样的,hc:Window加了个8,8,8,8的padding,搞不懂

Richardplus avatar Nov 28 '24 11:11 Richardplus

一个临时解决方案可以参考. 在窗口最大化时指定 NonClientFrameEdges 为 Bottom, 窗口的大小就正常且对布局没有影响. 切换成其他状态时就重新设置为 None. 但该属性只在 NET45 及以上版本才有, NET40 需要考虑其他解决方法, 只在 Windows 10 和 Windows 7 上试过.

#region fields

// ...

private readonly WindowChrome _chrome;

#endregion

#region ctor

// ...

public Window()
{
#if NET40
    _chrome = new WindowChrome
    {
        CornerRadius = new CornerRadius(),
        GlassFrameThickness = new Thickness(0, 0, 0, 1)
    };
#else
    _chrome = new WindowChrome
    {
        UseAeroCaptionButtons = false
    };

    if (SystemHelper.GetSystemVersionInfo() < SystemVersionInfo.Windows11_22H2)
    {
        _chrome.GlassFrameThickness = new Thickness(0, 0, 0, 1);
        _chrome.CornerRadius = new CornerRadius();
    }
#endif
    BindingOperations.SetBinding(_chrome, WindowChrome.CaptionHeightProperty,
        new Binding(NonClientAreaHeightProperty.Name) { Source = this });
    WindowChrome.SetWindowChrome(this, _chrome);
    _commonPadding = Padding;

    Loaded += (s, e) => OnLoaded(e);
}

#endregion

protected override void OnStateChanged(EventArgs e)
{
    base.OnStateChanged(e);
    if (WindowState == WindowState.Maximized)
    {
        BorderThickness = new Thickness();
        _tempNonClientAreaHeight = NonClientAreaHeight;
        NonClientAreaHeight += 8;
#if !NET40
        _chrome.NonClientFrameEdges = NonClientFrameEdges.Bottom;
#endif
    }
    else
    {
        BorderThickness = _actualBorderThickness;
        NonClientAreaHeight = _tempNonClientAreaHeight;
#if !NET40
        _chrome.NonClientFrameEdges = NonClientFrameEdges.None;
#endif
    }
}

ilreki avatar Jan 25 '25 06:01 ilreki