3 Copyright (c) 2003 Microsoft Corporation
7 Include file for SHGetUIMetric.
17 // Call RegisterWindowMessage on this string if you are interested in knowing
18 // when the UI metrics have changed. wParam will be 0, lParam will be one of the
19 // SHUIMETRICTYPE values to indicate what value has changed. Call SHGetUIMetrics
20 // to find out the new value.
22 #define SH_UIMETRIC_CHANGE TEXT("SH_UIMETRIC_CHANGE")
29 // Enumeration of metrics you can ask for. Note that you will only receive a
30 // notification for SHUIM_FONTSIZE_POINT when any these three values changes.
32 typedef enum tagSHUIMETRIC
34 SHUIM_INVALID
= 0, // Illegal
35 SHUIM_FONTSIZE_POINT
, // Application font size (hundredths of a point) -- buffer is pointer to DWORD
36 SHUIM_FONTSIZE_PIXEL
, // Application font size (in pixels) -- buffer is pointer to DWORD
37 SHUIM_FONTSIZE_PERCENTAGE
, // Application font size as percentage of normal -- buffer is pointer to DWORD
40 typedef HRESULT (*PSHGETUIMETRICS
)(SHUIMETRIC
, PVOID
, DWORD
, DWORD
*);
42 //////////////////////////////////////////////////////////////////////////////
43 // FUNCTION: SHGetUIMetrics
45 // PURPOSE: retrieves the shell's UI metrics. Although this function does not
46 // exist in the Pocket PC 2003 SDK, it exists AYGSHELL.DLL in newer
47 // versions of the Pocket PC. This function simply LoadLibrary's AYGSHELL
48 // and calls the function if it exists.
51 // SHUIMETRIC shuim: the metric to retrieve.
52 // PVOID pvBuffer: the retrieved data for the metric.
53 // DWORD cbBufferSize: the size of pvBuffer (should be sizeof(DWORD)).
54 // DWORD* pcbRequired: retrieves the minimum size of the buffer necessary
55 // to get the specified system UI metric. This can be NULL.
58 __inline HRESULT
SHGetUIMetrics(SHUIMETRIC shuim
, PVOID pvBuffer
, DWORD cbBufferSize
, DWORD
*pcbRequired
)
60 PSHGETUIMETRICS pSHGetUIMetrics
= (PSHGETUIMETRICS
)GetProcAddress(LoadLibrary(_T("AYGSHELL")), _T("SHGetUIMetrics"));
63 return pSHGetUIMetrics(shuim
, pvBuffer
, cbBufferSize
, pcbRequired
);
65 else if (pvBuffer
!= NULL
&& cbBufferSize
>= sizeof(DWORD
))
68 // Not supported on this version of Pocket PC, so come up with a reasonable default.
71 HFONT hFont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
72 GetObject(hFont
, sizeof(lf
), &lf
);
75 case SHUIM_FONTSIZE_POINT
:
77 HDC hDC
= GetDC(NULL
);
78 int nDPI
= GetDeviceCaps(hDC
, LOGPIXELSY
);
80 *(DWORD
*)pvBuffer
= (-lf
.lfHeight
* 7200) / nDPI
;
83 case SHUIM_FONTSIZE_PIXEL
: *(DWORD
*)pvBuffer
= -lf
.lfHeight
; break;
84 case SHUIM_FONTSIZE_PERCENTAGE
: *(DWORD
*)pvBuffer
= 100; break;
89 *pcbRequired
= sizeof(DWORD
);