Discussion:
How to get close button width on Windows Aero ?
(too old to reply)
max
2011-06-07 23:01:01 UTC
Permalink
In the Aero theme of Windows 7/Vista, the close button of the title
bar is wider than other buttons and the old method to get the button
width, using GetSystemMetrics(SM_CXSIZE) doesn't work anymore.

Is there a new way to get the width of that button?

Thanks,

Max
Nobody
2011-06-07 23:08:53 UTC
Permalink
Post by max
In the Aero theme of Windows 7/Vista, the close button of the title
bar is wider than other buttons and the old method to get the button
width, using GetSystemMetrics(SM_CXSIZE) doesn't work anymore.
Is there a new way to get the width of that button?
Check GetThemeMetric() and WP_CLOSEBUTTON.
max
2011-06-10 21:09:41 UTC
Permalink
Post by Nobody
Post by max
In the Aero theme of Windows 7/Vista, the close button of the title
bar is wider than other buttons and the old method to get the button
width, using GetSystemMetrics(SM_CXSIZE) doesn't work anymore.
Is there a new way to get the width of that button?
Check GetThemeMetric() and WP_CLOSEBUTTON.
Thanks for the answer, it seems to be the right function to get the
information but I haven't been able to get it work. I've tried several
things like

HRESULT hresult;
int width = 0;
HTHEME hTheme;
hTheme = ::OpenThemeData(m_hWnd, L"Window");
hresult = GetThemeMetric(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
TMT_WIDTH, &width);

but the value returned in hresult is always 0x80070490 "Element not
found." and width is not updated.

I have also tried:

SIZE sz;
hresult = GetThemePartSize(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
NULL, TS_TRUE, &sz);

which returns some valid data but it doesn't seem to be the real size
of the close button.
Nobody
2011-06-10 22:26:32 UTC
Permalink
Post by max
Thanks for the answer, it seems to be the right function to get the
information but I haven't been able to get it work. I've tried several
things like
HRESULT hresult;
int width = 0;
HTHEME hTheme;
hTheme = ::OpenThemeData(m_hWnd, L"Window");
hresult = GetThemeMetric(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
TMT_WIDTH, &width);
but the value returned in hresult is always 0x80070490 "Element not
found." and width is not updated.
SIZE sz;
hresult = GetThemePartSize(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
NULL, TS_TRUE, &sz);
which returns some valid data but it doesn't seem to be the real size
of the close button.
The class is "WINDOW", not "Window".
max
2011-06-13 18:04:48 UTC
Permalink
Post by Nobody
Post by max
Thanks for the answer, it seems to be the right function to get the
information but I haven't been able to get it work. I've tried several
things like
HRESULT hresult;
int width = 0;
HTHEME hTheme;
hTheme = ::OpenThemeData(m_hWnd, L"Window");
hresult = GetThemeMetric(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
TMT_WIDTH, &width);
but the value returned in hresult is always 0x80070490   "Element not
found." and width is not updated.
SIZE sz;
hresult = GetThemePartSize(hTheme, NULL, WP_CLOSEBUTTON, CBS_NORMAL,
NULL, TS_TRUE, &sz);
which returns some valid data but it doesn't seem to be the real size
of the close button.
The class is "WINDOW", not "Window".
I tried to change "Window" to "WINDOW", it didn't change anything. I
don't think that was the problem, the "hTheme" returned by
OpenThemeData was non-NULL with both "Window" and "WINDOW".

Loading...