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

Unable to remove thin border anymore from window using DWM_WINDOW_CORNER_PREFERENCE set to DWMWCP_DONOTROUND #4987

Open
alegnicitrix opened this issue Dec 19, 2024 · 1 comment

Comments

@alegnicitrix
Copy link

alegnicitrix commented Dec 19, 2024

Describe the bug

In previous version of the Windows App SDK, you used to be able to create a top-level window with a TransparentTintBackdrop and the DWM non-client rendering attribute to not use rounded corners on a window. This used to work on Windows App SDK versions 1.5.8 or earlier.

After upgrading to the latest version of the Windows App SDK (1.6.3 as of this writing), this has stopped working, and instead you get a thin border around the window, that I don't know how to remove. I have tried many different things, none of them have worked.

Image

Is there any way to remove this thin border?

Steps to reproduce the bug

Here is some sample code:

using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System;
using Windows.Foundation;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Dwm;
using WinUIEx;

using static Windows.Win32.PInvoke;

namespace MyApp;

internal sealed partial class MyWindow : Window
{
    public readonly WindowManager Manager;

    public MyWindow()
    {
        // Initialize the window.
        InitializeComponent();

        SystemBackdrop = new TransparentTintBackdrop();

        Manager = WindowManager.Get(this);
        Manager.PresenterKind = AppWindowPresenterKind.Overlapped;
        Manager.MinWidth = 0;
        Manager.MinHeight = 0;
        Manager.IsAlwaysOnTop = false;
        Manager.IsTitleBarVisible = false;
        Manager.IsMaximizable = false;
        Manager.IsMinimizable = false;
        Manager.IsResizable = false;

        var style = WindowStyle.TabStop | WindowStyle.Group | WindowStyle.ClipSiblings;
        this.SetWindowStyle(style);

        var exstyle = ExtendedWindowStyle.ToolWindow;
        this.SetExtendedWindowStyle(exstyle);

        // Disable rounded corners. This also has the effect of removing small thin border created
        // around the window. The order in which this function is called is important.
        unsafe
        {
            var hwnd = new HWND(WinRT.Interop.WindowNative.GetWindowHandle(this));
            uint pref = (uint)DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND;
            DwmSetWindowAttribute(hwnd, DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE, &pref, sizeof(uint));
        }

        // Show the window.
        this.Show();
    }
}

Expected behavior

It should be possible to create a window with no border, shadow effects, or anything else.

Screenshots

Image

NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@castorix
Copy link

castorix commented Dec 20, 2024

It seems similar to microsoft/microsoft-ui-xaml#9978

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

No branches or pull requests

2 participants