How to get the title bar height and width for aero and basic design

winapi

Solution

In unthemed Windows, `GetSystemMetrics(SM_CYCAPTION)` is the height of the text in the title bar; you need to add in the size of the frame and border padding (`GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYEDGE) * 2`).

For themed Windows (which is the default these days), `GetThemeSysSize` is most likely the function you're looking for; in particular, `GetThemeSysSize(SM_CXBORDER)` for the border width, and `GetThemeSysSize(SM_CYSIZE) + GetThemeSysSize(SM_CXPADDEDBORDER) * 2` for the title bar.

Problem

I am using `GetSystemMetrics(SM_CXSIZEFRAME)` for the width of the border, it works with the basic design, but not with aero, how can I improve it, so it works with aero? I am using `GetSystemMetrics(SM_CYCAPTION)` for the height of the title bar but the value is too small for both, basic and aero design, what am I doing wrong here?

Original source

Related problems