How to check rounded corner?

D.D.K-2637 966 Reputation points
2024-02-05T19:27:18.3733333+00:00

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

DWM_WINDOW_CORNER_PREFERENCE preference ; 
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

Windows development | Windows API - Win32
Developer technologies | .NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 49,636 Reputation points
    2024-02-05T19:57:36.2233333+00:00

    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 60,331 Reputation points
    2024-02-05T19:43:37.27+00:00

    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.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.