1

Actually I find there is a same demand post here. But I find some problem still, so I have to post another question here.

If I use snipaste to capture the toolbar. I can know the real title bar is 28 like this enter image description here

But if I use the method in that post like this:

#include<iostream>
#include <wtypes.h>
using namespace std;

int main() {
    cout << GetSystemMetrics(SM_CYCAPTION) << endl;
    return 0;
}

I will just get 23. Is there any thing I have missed? Or the 28 actually contain other portion besides the title bar? What can I do to find the real height of title bar with c++.

Jeroen
  • 1,168
  • 1
  • 12
  • 24
Make
  • 49
  • 2
  • 9

1 Answers1

4

Not precisely what you asked, but I often find this a useful metric:

int FindExtraWindowHeight(HWND h)
{
  RECT w, c;
  GetWindowRect(h, &w);
  GetClientRect(h, &c);
  return (w.bottom - w.top) - (c.bottom - c.top);
}

The difference between the window and the client area. So this will give you the title bar height + the border thickness.

noelicus
  • 14,468
  • 3
  • 92
  • 111