[SYSDM]
[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,
75 _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\Display"),
76 0, KEY_READ, &hKey) == ERROR_SUCCESS)
77 {
78 TCHAR szBuf[64];
79 DWORD dwSize = 64;
80
81 if (RegQueryValueEx(hKey, _T("DynaSettingsChange"), 0, NULL,
82 (LPBYTE)szBuf, &dwSize) == ERROR_SUCCESS)
83 {
84 switch (_ttoi(szBuf))
85 {
86 case 0:
87 SendDlgItemMessage(hWnd, IDC_RESTART_RB, BM_SETCHECK, 1, 1);
88 break;
89 case 1:
90 SendDlgItemMessage(hWnd, IDC_WITHOUTREBOOT_RB, BM_SETCHECK, 1, 1);
91 break;
92 case 3:
93 SendDlgItemMessage(hWnd, IDC_ASKME_RB, BM_SETCHECK, 1, 1);
94 break;
95 }
96 }
97
98 RegCloseKey(hKey);
99 }
100 }
101
102 INT_PTR CALLBACK
103 AdvGeneralPageProc(HWND hwndDlg,
104 UINT uMsg,
105 WPARAM wParam,
106 LPARAM lParam)
107 {
108 PDISPLAY_DEVICE_ENTRY DispDevice = NULL;
109 INT_PTR Ret = 0;
110
111 if (uMsg != WM_INITDIALOG)
112 DispDevice = (PDISPLAY_DEVICE_ENTRY)GetWindowLongPtr(hwndDlg, DWLP_USER);
113
114 switch (uMsg)
115 {
116 case WM_INITDIALOG:
117 DispDevice = (PDISPLAY_DEVICE_ENTRY)(((LPPROPSHEETPAGE)lParam)->lParam);
118 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)DispDevice);
119
120 InitFontSizeList(hwndDlg);
121 InitRadioButtons(hwndDlg);
122
123 Ret = TRUE;
124 break;
125 case WM_COMMAND:
126 switch (LOWORD(wParam))
127 {
128 case IDC_FONTSIZE_COMBO:
129 if (HIWORD(wParam) == CBN_SELCHANGE)
130 {
131 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
132 }
133 break;
134 case IDC_RESTART_RB:
135 case IDC_WITHOUTREBOOT_RB:
136 case IDC_ASKME_RB:
137 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
138 break;
139 }
140 break;
141 }
142
143 return Ret;
144 }