]>
Commit | Line | Data |
---|---|---|
e328b972 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/msw/private/metrics.h | |
3 | // Purpose: various helper functions to retrieve system metrics | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2008-09-05 | |
e328b972 VZ |
6 | // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org> |
7 | // Licence: wxWindows licence | |
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_MSW_PRIVATE_METRICS_H_ | |
11 | #define _WX_MSW_PRIVATE_METRICS_H_ | |
12 | ||
13 | namespace wxMSWImpl | |
14 | { | |
15 | ||
16 | // return NONCLIENTMETRICS as retrieved by SystemParametersInfo() | |
17 | // | |
18 | // currently this is not cached as the values may change when system settings | |
19 | // do and we don't react to this to invalidate the cache but it could be done | |
20 | // in the future | |
21 | // | |
22 | // MT-safety: this function is only meant to be called from the main thread | |
23 | inline const NONCLIENTMETRICS& GetNonClientMetrics() | |
24 | { | |
25 | static WinStruct<NONCLIENTMETRICS> nm; | |
26 | if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) ) | |
27 | { | |
28 | #if WINVER >= 0x0600 | |
29 | // a new field has been added to NONCLIENTMETRICS under Vista, so | |
30 | // the call to SystemParametersInfo() fails if we use the struct | |
31 | // size incorporating this new value on an older system -- retry | |
32 | // without it | |
33 | nm.cbSize -= sizeof(int); | |
34 | if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) ) | |
35 | #endif // WINVER >= 0x0600 | |
36 | { | |
37 | // maybe we should initialize the struct with some defaults? | |
9a83f860 | 38 | wxLogLastError(wxT("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)")); |
e328b972 VZ |
39 | } |
40 | } | |
41 | ||
42 | return nm; | |
43 | } | |
44 | ||
45 | } // namespace wxMSWImpl | |
46 | ||
47 | #endif // _WX_MSW_PRIVATE_METRICS_H_ | |
48 |