ReactOS  0.4.12-dev-51-ge94618b
systempage.c
Go to the documentation of this file.
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 
10 #include "precomp.h"
11 
14 
15 #define BUFFER_SIZE 512
16 
17 static BOOL
19 {
20  WCHAR szBuffer[BUFFER_SIZE];
21  HWND hDlgCtrl;
23  FILE* file;
24  UINT length;
26  HRESULT hr;
27 
28  hr = StringCbCopyW(szBuffer, sizeof(szBuffer), szPath);
29  if (FAILED(hr))
30  return FALSE;
31 
32  hr = StringCbCatW(szBuffer, sizeof(szBuffer), L"\\system.ini");
33  if (FAILED(hr))
34  return FALSE;
35 
36  file = _wfopen(szBuffer, L"rt");
37  if (!file)
38  return FALSE;
39 
40  hDlgCtrl = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
41 
42  while(!feof(file))
43  {
44  if (fgetws(szBuffer, BUFFER_SIZE, file))
45  {
46  length = wcslen(szBuffer);
47  if (length > 1)
48  {
49  szBuffer[length] = L'\0';
50  szBuffer[length - 1] = L'\0';
51  insert.hInsertAfter = TVI_LAST;
52  insert.item.mask = TVIF_TEXT;
53  insert.item.pszText = szBuffer;
54 
55  if (szBuffer[0] == L';' || szBuffer[0] == L'[')
56  {
57  /* Parent */
58  insert.hParent = NULL;
59  parent = TreeView_InsertItem(hDlgCtrl, &insert);
60  }
61  else
62  {
63  /* Child */
64  insert.hParent = parent;
65  TreeView_InsertItem(hDlgCtrl, &insert);
66  }
67  }
68  }
69  }
70 
71  fclose(file);
72 
73  return TRUE;
74 }
75 
76 static BOOL
78 {
79  WCHAR winDir[PATH_MAX];
80 
82  return LoadSystemIni(winDir, hDlg);
83 }
84 
85 
88 {
89  UNREFERENCED_PARAMETER(lParam);
90  UNREFERENCED_PARAMETER(wParam);
91  switch (message) {
92  case WM_INITDIALOG:
93  {
94  hSystemDialog = hDlg;
97  return TRUE;
98  }
99  }
100 
101  return 0;
102 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CALLBACK
Definition: compat.h:27
static int insert
Definition: xmllint.c:144
#define SWP_NOZORDER
Definition: winuser.h:1232
int32_t INT_PTR
Definition: typedefs.h:62
#define IDC_SYSTEM_TREE
Definition: resource.h:68
HWND hSystemPage
Definition: systempage.c:12
WPARAM wParam
Definition: combotst.c:138
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
UINT_PTR WPARAM
Definition: windef.h:207
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3379
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR CALLBACK SystemPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: systempage.c:87
static BOOL InitializeSystemDialog(HWND hDlg)
Definition: systempage.c:77
smooth NULL
Definition: ftsmooth.c:416
#define TVI_LAST
Definition: commctrl.h:3337
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
unsigned int BOOL
Definition: ntddk_ex.h:94
r parent
Definition: btrfs.c:2644
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define SWP_NOACTIVATE
Definition: winuser.h:1227
const char file[]
Definition: icontest.c:11
unsigned int UINT
Definition: ndis.h:50
#define PATH_MAX
Definition: types.h:280
static const WCHAR L[]
Definition: oid.c:1087
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
HWND hSystemDialog
Definition: systempage.c:13
#define BUFFER_SIZE
Definition: systempage.c:15
#define SWP_NOSIZE
Definition: winuser.h:1230
#define TVIF_TEXT
Definition: commctrl.h:3233
LPCWSTR szPath
Definition: env.c:35
static BOOL LoadSystemIni(WCHAR *szPath, HWND hDlg)
Definition: systempage.c:18
#define TVINSERTSTRUCT
Definition: commctrl.h:3369
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234