[WINHTTP] Sync with Wine Staging 3.9. CORE-14656
[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("SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\Software\\Fonts"),
30 0, KEY_READ, &hKey) == ERROR_SUCCESS)
31 {
32 dwSize = MAX_PATH;
33 dwType = REG_DWORD;
34
35 if (RegQueryValueEx(hKey, _T("LogPixels"), NULL, &dwType,
36 (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
37 {
38 dwValue = 0;
39 }
40
41 RegCloseKey(hKey);
42 }
43
44 for (;;)
45 {
46 TCHAR Buffer[LINE_LEN];
47 TCHAR Desc[LINE_LEN];
48
49 if (SetupGetStringField(&Context, 0, Buffer, sizeof(Buffer) / sizeof(TCHAR), NULL) &&
50 SetupGetIntField(&Context, 1, &ci))
51 {
52 _stprintf(Desc, _T("%s (%d DPI)"), Buffer, ci);
53 i = SendMessage(hFontSize, CB_ADDSTRING, 0, (LPARAM)Desc);
54 if (i != CB_ERR)
55 SendMessage(hFontSize, CB_SETITEMDATA, (WPARAM)i, (LPARAM)ci);
56
57 if ((int)dwValue == ci)
58 {
59 SendMessage(hFontSize, CB_SETCURSEL, (WPARAM)i, 0);
60 SetWindowText(GetDlgItem(hWnd, IDC_FONTSIZE_CUSTOM), Desc);
61 }
62 else
63 SendMessage(hFontSize, CB_SETCURSEL, 0, 0);
64 }
65
66 if (!SetupFindNextLine(&Context, &Context))
67 {
68 break;
69 }
70 }
71 }
72 }
73
74 SetupCloseInfFile(hInf);
75 }
76
77 static VOID
78 InitRadioButtons(HWND hWnd)
79 {
80 HKEY hKey;
81
82 if (RegOpenKeyEx(HKEY_CURRENT_USER,
83 _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\Display"),
84 0, KEY_READ, &hKey) == ERROR_SUCCESS)
85 {
86 TCHAR szBuf[64];
87 DWORD dwSize = 64;
88
89 if (RegQueryValueEx(hKey, _T("DynaSettingsChange"), 0, NULL,
90 (LPBYTE)szBuf, &dwSize) == ERROR_SUCCESS)
91 {
92 switch (_ttoi(szBuf))
93 {
94 case 0:
95 SendDlgItemMessage(hWnd, IDC_RESTART_RB, BM_SETCHECK, 1, 1);
96 break;
97 case 1:
98 SendDlgItemMessage(hWnd, IDC_WITHOUTREBOOT_RB, BM_SETCHECK, 1, 1);
99 break;
100 case 3:
101 SendDlgItemMessage(hWnd, IDC_ASKME_RB, BM_SETCHECK, 1, 1);
102 break;
103 }
104 }
105 else
106 SendDlgItemMessage(hWnd, IDC_WITHOUTREBOOT_RB, BM_SETCHECK, 1, 1);
107
108 RegCloseKey(hKey);
109 }
110 else
111 SendDlgItemMessage(hWnd, IDC_WITHOUTREBOOT_RB, BM_SETCHECK, 1, 1);
112 }
113
114 INT_PTR CALLBACK
115 AdvGeneralPageProc(HWND hwndDlg,
116 UINT uMsg,
117 WPARAM wParam,
118 LPARAM lParam)
119 {
120 PDISPLAY_DEVICE_ENTRY DispDevice = NULL;
121 INT_PTR Ret = 0;
122
123 if (uMsg != WM_INITDIALOG)
124 DispDevice = (PDISPLAY_DEVICE_ENTRY)GetWindowLongPtr(hwndDlg, DWLP_USER);
125
126 switch (uMsg)
127 {
128 case WM_INITDIALOG:
129 DispDevice = (PDISPLAY_DEVICE_ENTRY)(((LPPROPSHEETPAGE)lParam)->lParam);
130 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)DispDevice);
131
132 InitFontSizeList(hwndDlg);
133 InitRadioButtons(hwndDlg);
134
135 Ret = TRUE;
136 break;
137 case WM_COMMAND:
138 switch (LOWORD(wParam))
139 {
140 case IDC_FONTSIZE_COMBO:
141 if (HIWORD(wParam) == CBN_SELCHANGE)
142 {
143 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
144 }
145 break;
146 case IDC_RESTART_RB:
147 case IDC_WITHOUTREBOOT_RB:
148 case IDC_ASKME_RB:
149 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
150 break;
151 }
152 break;
153 }
154
155 return Ret;
156 }