SmartPDF - lightweight pdf viewer app for rosapps
[reactos.git] / rosapps / smartpdf / baseutils / ms_ui_shguim.h
1 /*++
2
3 Copyright (c) 2003 Microsoft Corporation
4
5 Abstract:
6
7 Include file for SHGetUIMetric.
8
9 --*/
10
11 #ifndef __SHGUIM_H__
12 #define __SHGUIM_H__
13
14 #include <windows.h>
15
16 //
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.
21 //
22 #define SH_UIMETRIC_CHANGE TEXT("SH_UIMETRIC_CHANGE")
23
24 #if _MSC_VER >= 1400
25 #include <aygshell.h>
26 #else
27
28 //
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.
31 //
32 typedef enum tagSHUIMETRIC
33 {
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
38 } SHUIMETRIC;
39
40 typedef HRESULT (*PSHGETUIMETRICS)(SHUIMETRIC, PVOID, DWORD, DWORD*);
41
42 //////////////////////////////////////////////////////////////////////////////
43 // FUNCTION: SHGetUIMetrics
44 //
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.
49 //
50 // ON ENTRY:
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.
56 //
57
58 __inline HRESULT SHGetUIMetrics(SHUIMETRIC shuim, PVOID pvBuffer, DWORD cbBufferSize, DWORD *pcbRequired)
59 {
60 PSHGETUIMETRICS pSHGetUIMetrics = (PSHGETUIMETRICS)GetProcAddress(LoadLibrary(_T("AYGSHELL")), _T("SHGetUIMetrics"));
61 if (pSHGetUIMetrics)
62 {
63 return pSHGetUIMetrics(shuim, pvBuffer, cbBufferSize, pcbRequired);
64 }
65 else if (pvBuffer != NULL && cbBufferSize >= sizeof(DWORD))
66 {
67 //
68 // Not supported on this version of Pocket PC, so come up with a reasonable default.
69 //
70 LOGFONT lf;
71 HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT);
72 GetObject(hFont, sizeof(lf), &lf);
73 switch (shuim)
74 {
75 case SHUIM_FONTSIZE_POINT:
76 {
77 HDC hDC = GetDC(NULL);
78 int nDPI = GetDeviceCaps(hDC, LOGPIXELSY);
79 ReleaseDC(NULL, hDC);
80 *(DWORD*)pvBuffer = (-lf.lfHeight * 7200) / nDPI;
81 break;
82 }
83 case SHUIM_FONTSIZE_PIXEL: *(DWORD*)pvBuffer = -lf.lfHeight; break;
84 case SHUIM_FONTSIZE_PERCENTAGE: *(DWORD*)pvBuffer = 100; break;
85 }
86 }
87 else if (pcbRequired)
88 {
89 *pcbRequired = sizeof(DWORD);
90 }
91 return S_OK;
92 }
93
94 #endif
95
96 #endif