I don't know if these will be useful for a WinUI3 application but you might want to take a look at AdjustWindowRect, AdjustWindowRectEx and AdjustWindowRectExForDpi.
WinUI3 : How to get Width/ Height of the windows default border and titlebar
Hi,
I'm working on WinUI3 desktop application in c++ without using XAML. After creating the WinUi3 window, I set its height and width with SetWindowPos with (1000, 600) dimension. But when I get the Window.SizeChanged Event the Width and height will be lesser than the one which i have set, which is (984,561).
As i can understand, this is the client area not the whole windows area.
So now when i set Height and width of the window, i will have to dimension the contents as per the Client area not the height and width i have set.
So how can i get Width/ Height of the windows default border and titlebar (NON-cleant area) so that i can dimension my contents correctly.
[ I could have used GetClientArea(), but my dimensioning will happen before the window is created, so i want to know the client area before the window is created, so im checking for default non client area sizes]
I tried using GetSystemMetrics (SM_CXSIZEFRAME); but the result was not adding up.
What is the right way to get windows default height/width on the border and titlebar?