list services
[reactos.git] / reactos / subsys / system / msconfig / msconfig.c
1 #include <precomp.h>
2
3 HINSTANCE hInst = 0;
4
5 HWND hMainWnd; /* Main Window */
6 HWND hTabWnd; /* Tab Control Window */
7
8
9 BOOL OnCreate(HWND hWnd)
10 {
11 TCHAR szTemp[256];
12 TCITEM item;
13
14 hTabWnd = GetDlgItem(hWnd, IDC_TAB);
15 hToolsPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TOOLS_PAGE), hWnd, ToolsPageWndProc);
16 hServicesPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SERVICES_PAGE), hWnd, ServicesPageWndProc);
17 hStartupPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_STARTUP_PAGE), hWnd, StartupPageWndProc);
18
19 // Insert Tab Pages
20 LoadString(hInst, IDS_TAB_GENERAL, szTemp, 256);
21 memset(&item, 0, sizeof(TCITEM));
22 item.mask = TCIF_TEXT;
23 item.pszText = szTemp;
24 TabCtrl_InsertItem(hTabWnd, 0, &item);
25
26 LoadString(hInst, IDS_TAB_SYSTEM, szTemp, 256);
27 memset(&item, 0, sizeof(TCITEM));
28 item.mask = TCIF_TEXT;
29 item.pszText = szTemp;
30 TabCtrl_InsertItem(hTabWnd, 1, &item);
31
32 LoadString(hInst, IDS_TAB_FREELDR, szTemp, 256);
33 memset(&item, 0, sizeof(TCITEM));
34 item.mask = TCIF_TEXT;
35 item.pszText = szTemp;
36 TabCtrl_InsertItem(hTabWnd, 2, &item);
37
38 LoadString(hInst, IDS_TAB_SERVICES, szTemp, 256);
39 memset(&item, 0, sizeof(TCITEM));
40 item.mask = TCIF_TEXT;
41 item.pszText = szTemp;
42 TabCtrl_InsertItem(hTabWnd, 3, &item);
43
44 LoadString(hInst, IDS_TAB_STARTUP, szTemp, 256);
45 memset(&item, 0, sizeof(TCITEM));
46 item.mask = TCIF_TEXT;
47 item.pszText = szTemp;
48 TabCtrl_InsertItem(hTabWnd, 4, &item);
49
50 LoadString(hInst, IDS_TAB_TOOLS, szTemp, 256);
51 memset(&item, 0, sizeof(TCITEM));
52 item.mask = TCIF_TEXT;
53 item.pszText = szTemp;
54 TabCtrl_InsertItem(hTabWnd, 5, &item);
55
56 return TRUE;
57 }
58
59
60 void MsConfig_OnTabWndSelChange(void)
61 {
62 switch (TabCtrl_GetCurSel(hTabWnd)) {
63 case 0: //General
64 ShowWindow(hToolsPage, SW_HIDE);
65 ShowWindow(hStartupPage, SW_HIDE);
66 //ShowWindow(hFreeLdrPage, SW_HIDE);
67 ShowWindow(hServicesPage, SW_HIDE);
68 //BringWindowToTop(hFreeLdrPage);
69 break;
70 case 1: //SYSTEM.INI
71 ShowWindow(hToolsPage, SW_HIDE);
72 ShowWindow(hStartupPage, SW_HIDE);
73 //ShowWindow(hFreeLdrPage, SW_SHOW);
74 ShowWindow(hServicesPage, SW_HIDE);
75 //BringWindowToTop(hFreeLdrPage);
76 break;
77 case 2: //Freeldr
78 ShowWindow(hToolsPage, SW_HIDE);
79 ShowWindow(hStartupPage, SW_HIDE);
80 //ShowWindow(hFreeLdrPage, SW_SHOW);
81 ShowWindow(hServicesPage, SW_HIDE);
82 //BringWindowToTop(hFreeLdrPage);
83 break;
84 case 3: //Services
85 ShowWindow(hToolsPage, SW_HIDE);
86 ShowWindow(hStartupPage, SW_HIDE);
87 //ShowWindow(hFreeLdrPage, SW_HIDE);
88 ShowWindow(hServicesPage, SW_SHOW);
89 BringWindowToTop(hServicesPage);
90 break;
91 case 4: //startup
92 ShowWindow(hToolsPage, SW_HIDE);
93 ShowWindow(hStartupPage, SW_SHOW);
94 //ShowWindow(hFreeLdrPage, SW_HIDE);
95 ShowWindow(hServicesPage, SW_HIDE);
96 BringWindowToTop(hStartupPage);
97 break;
98 case 5: //Tools
99 ShowWindow(hToolsPage, SW_SHOW);
100 ShowWindow(hStartupPage, SW_HIDE);
101 //ShowWindow(hFreeLdrPage, SW_HIDE);
102 ShowWindow(hServicesPage, SW_HIDE);
103 BringWindowToTop(hToolsPage);
104 break;
105 }
106 }
107
108
109 /* Message handler for dialog box. */
110 INT_PTR CALLBACK
111 MsConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
112 {
113 int idctrl;
114 LPNMHDR pnmh;
115
116 switch (message) {
117 case WM_INITDIALOG:
118 hMainWnd = hDlg;
119 return OnCreate(hDlg);
120
121 case WM_COMMAND:
122
123 if (LOWORD(wParam) == IDOK) {
124 //MsConfig_OnSaveChanges();
125 }
126
127 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
128 EndDialog(hDlg, LOWORD(wParam));
129 return TRUE;
130 }
131 break;
132
133 case WM_NOTIFY:
134 idctrl = (int)wParam;
135 pnmh = (LPNMHDR)lParam;
136 if ((pnmh->hwndFrom == hTabWnd) &&
137 (pnmh->idFrom == IDC_TAB) &&
138 (pnmh->code == TCN_SELCHANGE))
139 {
140 MsConfig_OnTabWndSelChange();
141 }
142 break;
143
144 case WM_DESTROY:
145 DestroyWindow(hToolsPage);
146 DestroyWindow(hServicesPage);
147 DestroyWindow(hStartupPage);
148 return DefWindowProc(hDlg, message, wParam, lParam);
149
150 }
151
152 return 0;
153 }
154
155 int APIENTRY WinMain(HINSTANCE hInstance,
156 HINSTANCE hPrevInstance,
157 LPSTR lpCmdLine,
158 int nCmdShow)
159 {
160
161 INITCOMMONCONTROLSEX InitControls;
162
163 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
164 InitControls.dwICC = ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES;
165 InitCommonControlsEx(&InitControls);
166
167 hInst = hInstance;
168
169 DialogBox(hInst, (LPCTSTR)IDD_MSCONFIG_DIALOG, NULL, MsConfigWndProc);
170
171 return 0;
172 }
173
174 /* EOF */