Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LickBag opened this issue Sep 12, 2024 · 3 comments

Comments

@LickBag
Copy link

LickBag commented Sep 12, 2024

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

@imoonstal
Copy link

imoonstal commented Nov 12, 2024

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

@Richardplus
Copy link

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

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

@ilreki
Copy link

ilreki commented Jan 25, 2025

一个临时解决方案可以参考.
在窗口最大化时指定 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
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants