[NTOSKRNL]
[reactos.git] / base / applications / msconfig / systempage.c
1 /*
2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/msconfig/systempage.c
5 * PURPOSE: System page message handler
6 * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de>
7 * 2011 Gregor Schneider <Gregor.Schneider@reactos.org>
8 */
9 #include <precomp.h>
10
11 HWND hSystemPage;
12 HWND hSystemDialog;
13
14 #define BUFFER_SIZE 512
15
16 static BOOL
17 LoadSystemIni(WCHAR * szPath, HWND hDlg)
18 {
19 WCHAR szBuffer[BUFFER_SIZE];
20 HWND hDlgCtrl;
21 HTREEITEM parent = NULL;
22 FILE* file;
23 UINT length;
24 TVINSERTSTRUCT insert;
25
26 wcscpy(szBuffer, szPath);
27 wcscat(szBuffer, L"\\system.ini");
28
29 file = _wfopen(szBuffer, L"rt");
30 if (!file)
31 return FALSE;
32
33 hDlgCtrl = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
34
35 while(!feof(file))
36 {
37 if (fgetws(szBuffer, BUFFER_SIZE, file))
38 {
39 length = wcslen(szBuffer);
40 if (length > 1)
41 {
42 szBuffer[length] = L'\0';
43 szBuffer[length - 1] = L'\0';
44 insert.hInsertAfter = TVI_LAST;
45 insert.item.mask = TVIF_TEXT;
46 insert.item.pszText = szBuffer;
47
48 if (szBuffer[0] == L';' || szBuffer[0] == L'[')
49 {
50 /* Parent */
51 insert.hParent = NULL;
52 parent = TreeView_InsertItem(hDlgCtrl, &insert);
53 }
54 else
55 {
56 /* Child */
57 insert.hParent = parent;
58 TreeView_InsertItem(hDlgCtrl, &insert);
59 }
60 }
61 }
62 }
63
64 fclose(file);
65
66 return TRUE;
67 }
68
69 static BOOL
70 InitializeSystemDialog(HWND hDlg)
71 {
72 WCHAR winDir[PATH_MAX];
73
74 GetWindowsDirectoryW(winDir, PATH_MAX);
75 return LoadSystemIni(winDir, hDlg);
76 }
77
78
79 INT_PTR CALLBACK
80 SystemPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
81 {
82 UNREFERENCED_PARAMETER(lParam);
83 UNREFERENCED_PARAMETER(wParam);
84 switch (message) {
85 case WM_INITDIALOG:
86 {
87 hSystemDialog = hDlg;
88 SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
89 InitializeSystemDialog(hDlg);
90 return TRUE;
91 }
92 }
93
94 return 0;
95 }