Sync with trunk r62754.
[reactos.git] / dll / cpl / desk / general.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * FILE: dll/cpl/desk/general.c
5 * PURPOSE: Advanced General settings
6 */
7
8 #include "desk.h"
9
10 static VOID
11 InitFontSizeList(HWND hWnd)
12 {
13 HINF hInf;
14 HKEY hKey;
15 HWND hFontSize;
16 INFCONTEXT Context;
17 int i, ci = 0;
18 DWORD dwSize, dwValue, dwType;
19
20 hFontSize = GetDlgItem(hWnd, IDC_FONTSIZE_COMBO);
21
22 hInf = SetupOpenInfFile(_T("font.inf"), NULL,
23 INF_STYLE_WIN4, NULL);
24
25 if (hInf != INVALID_HANDLE_VALUE)
26 {
27 if (SetupFindFirstLine(hInf, _T("Font Sizes"), NULL, &Context))
28 {
29 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontDPI"),
30 0, KEY_READ, &hKey) == ERROR_SUCCESS)
31 for (;;)
32 {
33 TCHAR Buffer[LINE_LEN];
34 TCHAR Desc[LINE_LEN];
35
36 if (SetupGetStringField(&Context, 0, Buffer, sizeof(Buffer) / sizeof(TCHAR), NULL) &&
37 SetupGetIntField(&Context, 1, &ci))
38 {
39 _stprintf(Desc, _T("%s (%d DPI)"), Buffer, ci);
40 i = SendMessage(hFontSize, CB_ADDSTRING, 0, (LPARAM)Desc);
41 if (i != CB_ERR)
42 SendMessage(hFontSize, CB_SETITEMDATA, (WPARAM)i, (LPARAM)ci);
43
44 dwSize = MAX_PATH;
45 dwType = REG_DWORD;
46
47 if (RegQueryValueEx(hKey, _T("LogPixels"), NULL,
48 &dwType, (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS)
49 {
50 if ((int)dwValue == ci)
51 {
52 SendMessage(hFontSize, CB_SETCURSEL, (WPARAM)i, 0);
53 SetWindowText(GetDlgItem(hWnd, IDC_FONTSIZE_CUSTOM), Desc);
54 }
55 }
56 }
57
58 if (!SetupFindNextLine(&Context, &Context))
59 {
60 RegCloseKey(hKey);
61 break;
62 }
63 }
64 }
65 }
66
67 SetupCloseInfFile(hInf);
68 }
69
70 static VOID
71 InitRadioButtons(HWND hWnd)
72 {
73 HKEY hKey;
74
75 if (RegOpenKeyEx(HKEY_CURRENT_USER,
76 _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\Display"),
77 0, KEY_READ, &hKey) == ERROR_SUCCESS)
78 {
79 TCHAR szBuf[64];
80 DWORD dwSize = 64;
81
82 if (RegQueryValueEx(hKey, _T("DynaSettingsChange"), 0, NULL,
83 (LPBYTE)szBuf, &dwSize) == ERROR_SUCCESS)
84 {
85 switch (_ttoi(szBuf))
86 {
87 case 0:
88 SendDlgItemMessage(hWnd, IDC_RESTART_RB, BM_SETCHECK, 1, 1);
89 break;
90 case 1:
91 SendDlgItemMessage(hWnd, IDC_WITHOUTREBOOT_RB, BM_SETCHECK, 1, 1);
92 break;
93 case 3:
94 SendDlgItemMessage(hWnd, IDC_ASKME_RB, BM_SETCHECK, 1, 1);
95 break;
96 }
97 }
98
99 RegCloseKey(hKey);
100 }
101 }
102
103 INT_PTR CALLBACK
104 AdvGeneralPageProc(HWND hwndDlg,
105 UINT uMsg,
106 WPARAM wParam,
107 LPARAM lParam)
108 {
109 PDISPLAY_DEVICE_ENTRY DispDevice = NULL;
110 INT_PTR Ret = 0;
111
112 if (uMsg != WM_INITDIALOG)
113 DispDevice = (PDISPLAY_DEVICE_ENTRY)GetWindowLongPtr(hwndDlg, DWLP_USER);
114
115 switch (uMsg)
116 {
117 case WM_INITDIALOG:
118 DispDevice = (PDISPLAY_DEVICE_ENTRY)(((LPPROPSHEETPAGE)lParam)->lParam);
119 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)DispDevice);
120
121 InitFontSizeList(hwndDlg);
122 InitRadioButtons(hwndDlg);
123
124 Ret = TRUE;
125 break;
126 case WM_COMMAND:
127 switch (LOWORD(wParam))
128 {
129 case IDC_FONTSIZE_COMBO:
130 if (HIWORD(wParam) == CBN_SELCHANGE)
131 {
132 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
133 }
134 break;
135 case IDC_RESTART_RB:
136 case IDC_WITHOUTREBOOT_RB:
137 case IDC_ASKME_RB:
138 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
139 break;
140 }
141 break;
142 }
143
144 return Ret;
145 }