WinUI3 : How to get Width/ Height of the windows default border and titlebar

Harshithraj1871 1,516 Reputation points


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?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
749 questions
{count} votes

0 additional answers

Sort by: Most helpful