How to check rounded corner?

DangDKhanh-2637 941 Reputation points

Hi, I'm using the following code to check rounded on win11.

DwmGetWindowAttribute(hwnd,WINDOW_CORNER_PREFERENCE, ref preference , sizeof(uint));

However it doesn't work as expected. I used window + left arrow to align it, clearly its state at this time is perpendicular. However preference always returns 2. Is there any other way to fix it? Thanks you! User's image

Microsoft Technologies based on the .NET software framework.
3,144 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,352 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 38,856 Reputation points

    According to Apply rounded corners in desktop apps for Windows 11 "By design, apps are not rounded when maximized, snapped, running in a Virtual Machine (VM), running on a Windows Virtual Desktop (WVD), or running as a Windows Defender Application Guard (WDAG) window." That would explain why your snapped window does not have rounded corners.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Michael Taylor 43,976 Reputation points

    The call returns the preference, not whether it actually is or not. As discussed in the docs for having rounded corners here a snapped window doesn't have rounded corners whether its preference was to have them or not. There are quite a few other situations where rounding isn't supported even if the preference is to have it.

    AFAIK there isn't a way to determine if the corners are actually rounded on a window or not. I guess you could brute force a solution but since it is part of the chrome then I'm not sure it'll work. Windows still sees it as a rectangle. You might be able to look at the window styles but I think you'd need to run Spy++ to see if there is a difference. I've never looked.

    1 person found this answer helpful.