3

I am working on some code about capturing mouse location. I have a frame created by using wxWidgets, and I am working on an issue which I need to get the title bar height. Is there a good way to get the size of title bar?

Here is a simple illustration of what I need: title bar height (h)

Tunahan
  • 303
  • 4
  • 22

2 Answers2

4

wxWidgets provides a mechanism for this (and much else beside) called wxSystemSettings::GetMetric.

static int wxSystemSettings::GetMetric(wxSystemMetric index, wxWindow* win = NULL);

You can retrieve 'global' values by leaving win as NULL or you can pass in a specific window.

https://docs.wxwidgets.org/trunk/classwx_system_settings.html#aa18e3b5794dc4193c4b0668d28d4933a

The metric you probably want is wxSYS_CAPTION_Y.

https://docs.wxwidgets.org/trunk/settings_8h.html#a0f2b19d7a3717cdbef5a04cb05ab8f26

avariant
  • 2,234
  • 5
  • 25
  • 33
0

It should be the y coordinate of what wxWindow::GetClientAreaOrigin() returns.

catalin
  • 1,927
  • 20
  • 20
  • Both of the `x` and `y` values of `wxWindow::GetClientAreaOrigin()` returns zero, then I couldn't get the right thing. – Tunahan Apr 09 '19 at 13:16