571ba5bbd9ba59ea4db9961152ba4c53eaf82760
[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
18 // Insert Tab Pages
19 LoadString(hInst, IDS_TAB_GENERAL, szTemp, 256);
20 memset(&item, 0, sizeof(TCITEM));
21 item.mask = TCIF_TEXT;
22 item.pszText = szTemp;
23 TabCtrl_InsertItem(hTabWnd, 0, &item);
24
25 LoadString(hInst, IDS_TAB_FREELDR, szTemp, 256);
26 memset(&item, 0, sizeof(TCITEM));
27 item.mask = TCIF_TEXT;
28 item.pszText = szTemp;
29 TabCtrl_InsertItem(hTabWnd, 1, &item);
30
31 LoadString(hInst, IDS_TAB_SERVICES, szTemp, 256);
32 memset(&item, 0, sizeof(TCITEM));
33 item.mask = TCIF_TEXT;
34 item.pszText = szTemp;
35 TabCtrl_InsertItem(hTabWnd, 2, &item);
36
37 LoadString(hInst, IDS_TAB_STARTUP, szTemp, 256);
38 memset(&item, 0, sizeof(TCITEM));
39 item.mask = TCIF_TEXT;
40 item.pszText = szTemp;
41 TabCtrl_InsertItem(hTabWnd, 3, &item);
42
43 LoadString(hInst, IDS_TAB_TOOLS, szTemp, 256);
44 memset(&item, 0, sizeof(TCITEM));
45 item.mask = TCIF_TEXT;
46 item.pszText = szTemp;
47 TabCtrl_InsertItem(hTabWnd, 4, &item);
48
49 return TRUE;
50 }
51
52
53 void MsConfig_OnTabWndSelChange(void)
54 {
55 switch (TabCtrl_GetCurSel(hTabWnd)) {
56 case 0:
57 ShowWindow(hToolsPage, SW_HIDE);
58 //ShowWindow(hFreeLdrPage, SW_SHOW);
59 ShowWindow(hServicesPage, SW_HIDE);
60 //BringWindowToTop(hFreeLdrPage);
61 break;
62 case 1:
63 ShowWindow(hToolsPage, SW_HIDE);
64 //ShowWindow(hFreeLdrPage, SW_SHOW);
65 ShowWindow(hServicesPage, SW_HIDE);
66 //BringWindowToTop(hFreeLdrPage);
67 break;
68 case 2:
69 ShowWindow(hToolsPage, SW_HIDE);
70 //ShowWindow(hFreeLdrPage, SW_HIDE);
71 ShowWindow(hServicesPage, SW_SHOW);
72 //BringWindowToTop(hFreeLdrPage);
73 break;
74 case 3:
75 ShowWindow(hToolsPage, SW_HIDE);
76 //ShowWindow(hFreeLdrPage, SW_HIDE);
77 ShowWindow(hServicesPage, SW_HIDE);
78 //BringWindowToTop(hFreeLdrPage);
79 break;
80 case 4:
81 ShowWindow(hToolsPage, SW_SHOW);
82 //ShowWindow(hFreeLdrPage, SW_HIDE);
83 ShowWindow(hServicesPage, SW_HIDE);
84 BringWindowToTop(hToolsPage);
85 break;
86 }
87 }
88
89
90 /* Message handler for dialog box. */
91 INT_PTR CALLBACK
92 MsConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
93 {
94 int idctrl;
95 LPNMHDR pnmh;
96
97 switch (message) {
98 case WM_INITDIALOG:
99 hMainWnd = hDlg;
100 return OnCreate(hDlg);
101
102 case WM_COMMAND:
103
104 if (LOWORD(wParam) == IDOK) {
105 //MsConfig_OnSaveChanges();
106 }
107
108 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
109 EndDialog(hDlg, LOWORD(wParam));
110 return TRUE;
111 }
112 break;
113
114 case WM_NOTIFY:
115 idctrl = (int)wParam;
116 pnmh = (LPNMHDR)lParam;
117 if ((pnmh->hwndFrom == hTabWnd) &&
118 (pnmh->idFrom == IDC_TAB) &&
119 (pnmh->code == TCN_SELCHANGE))
120 {
121 MsConfig_OnTabWndSelChange();
122 }
123 break;
124
125 case WM_DESTROY:
126 DestroyWindow(hToolsPage);
127 DestroyWindow(hServicesPage);
128 return DefWindowProc(hDlg, message, wParam, lParam);
129
130 }
131
132 return 0;
133 }
134
135 int APIENTRY WinMain(HINSTANCE hInstance,
136 HINSTANCE hPrevInstance,
137 LPSTR lpCmdLine,
138 int nCmdShow)
139 {
140
141 INITCOMMONCONTROLSEX InitControls;
142
143 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
144 InitControls.dwICC = ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES;
145 InitCommonControlsEx(&InitControls);
146
147 hInst = hInstance;
148
149 DialogBox(hInst, (LPCTSTR)IDD_MSCONFIG_DIALOG, NULL, MsConfigWndProc);
150
151 return 0;
152 }
153
154 /* EOF */