microsoft / microsoft/microsoft-ui-xaml

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

Open
#10,274 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-AppWindow needs-triage
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### 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](https://github.com/user-attachments/assets/f56d6b39-1881-4a38-9926-871a463c07a2)

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](https://github.com/user-attachments/assets/f56d6b39-1881-4a38-9926-871a463c07a2)

### 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_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the sample on Windows 11 22H2 with Windows App SDK 1.6.3, then compare the behavior with version 1.5.8. Inspect the DWM_WINDOW_CORNER_PREFERENCE call and its ordering relative to Show(), using the provided MyWindow constructor as the entry point. Done means a top-level window can use TransparentTintBackdrop with no thin border or unwanted shadow effects.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.