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