1 /* 2 * PROJECT: ReactOS Applications 3 * LICENSE: LGPL - See COPYING in the top level directory 4 * FILE: base/applications/msconfig.c 5 * PURPOSE: msconfig main dialog 6 * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de> 7 * 8 */ 9 #include <precomp.h> 10 11 HINSTANCE hInst = 0; 12 13 HWND hMainWnd; /* Main Window */ 14 HWND hTabWnd; /* Tab Control Window */ 15 UINT uXIcon = 0, uYIcon = 0; /* Icon sizes */ 16 HICON hDialogIcon = NULL; 17 18 void MsConfig_OnTabWndSelChange(void); 19 20 BOOL OnCreate(HWND hWnd) 21 { 22 TCHAR szTemp[256]; 23 TCITEM item; 24 25 hTabWnd = GetDlgItem(hWnd, IDC_TAB); 26 hGeneralPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_GENERAL_PAGE), hWnd, GeneralPageWndProc); 27 hSystemPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SYSTEM_PAGE), hWnd, SystemPageWndProc); 28 hFreeLdrPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FREELDR_PAGE), hWnd, FreeLdrPageWndProc); 29 hServicesPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SERVICES_PAGE), hWnd, ServicesPageWndProc); 30 hStartupPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_STARTUP_PAGE), hWnd, StartupPageWndProc); 31 hToolsPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TOOLS_PAGE), hWnd, ToolsPageWndProc); 32 33 LoadString(hInst, IDS_MSCONFIG, szTemp, 256); 34 SetWindowText(hWnd, szTemp); 35 36 // Insert Tab Pages 37 LoadString(hInst, IDS_TAB_GENERAL, szTemp, 256); 38 memset(&item, 0, sizeof(TCITEM)); 39 item.mask = TCIF_TEXT; 40 item.pszText = szTemp; 41 (void)TabCtrl_InsertItem(hTabWnd, 0, &item); 42 43 LoadString(hInst, IDS_TAB_SYSTEM, szTemp, 256); 44 memset(&item, 0, sizeof(TCITEM)); 45 item.mask = TCIF_TEXT; 46 item.pszText = szTemp; 47 (void)TabCtrl_InsertItem(hTabWnd, 1, &item); 48 49 LoadString(hInst, IDS_TAB_FREELDR, szTemp, 256); 50 memset(&item, 0, sizeof(TCITEM)); 51 item.mask = TCIF_TEXT; 52 item.pszText = szTemp; 53 (void)TabCtrl_InsertItem(hTabWnd, 2, &item); 54 55 LoadString(hInst, IDS_TAB_SERVICES, szTemp, 256); 56 memset(&item, 0, sizeof(TCITEM)); 57 item.mask = TCIF_TEXT; 58 item.pszText = szTemp; 59 (void)TabCtrl_InsertItem(hTabWnd, 3, &item); 60 61 LoadString(hInst, IDS_TAB_STARTUP, szTemp, 256); 62 memset(&item, 0, sizeof(TCITEM)); 63 item.mask = TCIF_TEXT; 64 item.pszText = szTemp; 65 (void)TabCtrl_InsertItem(hTabWnd, 4, &item); 66 67 LoadString(hInst, IDS_TAB_TOOLS, szTemp, 256); 68 memset(&item, 0, sizeof(TCITEM)); 69 item.mask = TCIF_TEXT; 70 item.pszText = szTemp; 71 (void)TabCtrl_InsertItem(hTabWnd, 5, &item); 72 73 MsConfig_OnTabWndSelChange(); 74 75 return TRUE; 76 } 77 78 79 void MsConfig_OnTabWndSelChange(void) 80 { 81 switch (TabCtrl_GetCurSel(hTabWnd)) { 82 case 0: //General 83 ShowWindow(hGeneralPage, SW_SHOW); 84 ShowWindow(hSystemPage, SW_HIDE); 85 ShowWindow(hFreeLdrPage, SW_HIDE); 86 ShowWindow(hServicesPage, SW_HIDE); 87 ShowWindow(hStartupPage, SW_HIDE); 88 ShowWindow(hToolsPage, SW_HIDE); 89 BringWindowToTop(hGeneralPage); 90 break; 91 case 1: //SYSTEM.INI 92 ShowWindow(hGeneralPage, SW_HIDE); 93 ShowWindow(hSystemPage, SW_SHOW); 94 ShowWindow(hToolsPage, SW_HIDE); 95 ShowWindow(hStartupPage, SW_HIDE); 96 ShowWindow(hFreeLdrPage, SW_HIDE); 97 ShowWindow(hServicesPage, SW_HIDE); 98 BringWindowToTop(hSystemPage); 99 break; 100 case 2: //Freeldr 101 ShowWindow(hGeneralPage, SW_HIDE); 102 ShowWindow(hSystemPage, SW_HIDE); 103 ShowWindow(hFreeLdrPage, SW_SHOW); 104 ShowWindow(hServicesPage, SW_HIDE); 105 ShowWindow(hStartupPage, SW_HIDE); 106 ShowWindow(hToolsPage, SW_HIDE); 107 BringWindowToTop(hFreeLdrPage); 108 break; 109 case 3: //Services 110 ShowWindow(hGeneralPage, SW_HIDE); 111 ShowWindow(hSystemPage, SW_HIDE); 112 ShowWindow(hFreeLdrPage, SW_HIDE); 113 ShowWindow(hServicesPage, SW_SHOW); 114 ShowWindow(hStartupPage, SW_HIDE); 115 ShowWindow(hToolsPage, SW_HIDE); 116 BringWindowToTop(hServicesPage); 117 break; 118 case 4: //startup 119 ShowWindow(hGeneralPage, SW_HIDE); 120 ShowWindow(hSystemPage, SW_HIDE); 121 ShowWindow(hFreeLdrPage, SW_HIDE); 122 ShowWindow(hServicesPage, SW_HIDE); 123 ShowWindow(hStartupPage, SW_SHOW); 124 ShowWindow(hToolsPage, SW_HIDE); 125 BringWindowToTop(hStartupPage); 126 break; 127 case 5: //Tools 128 ShowWindow(hGeneralPage, SW_HIDE); 129 ShowWindow(hSystemPage, SW_HIDE); 130 ShowWindow(hFreeLdrPage, SW_HIDE); 131 ShowWindow(hServicesPage, SW_HIDE); 132 ShowWindow(hStartupPage, SW_HIDE); 133 ShowWindow(hToolsPage, SW_SHOW); 134 BringWindowToTop(hToolsPage); 135 break; 136 } 137 } 138 139 140 static 141 VOID 142 SetDialogIcon(HWND hDlg) 143 { 144 if (hDialogIcon) DestroyIcon(hDialogIcon); 145 146 hDialogIcon = LoadImage(GetModuleHandle(NULL), 147 MAKEINTRESOURCE(IDI_APPICON), 148 IMAGE_ICON, 149 uXIcon, 150 uYIcon, 151 0); 152 SendMessage(hDlg, 153 WM_SETICON, 154 ICON_SMALL, 155 (LPARAM)hDialogIcon); 156 } 157 158 159 /* Message handler for dialog box. */ 160 INT_PTR CALLBACK 161 MsConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 162 { 163 LPNMHDR pnmh; 164 UINT uXIconNew, uYIconNew; 165 166 switch (message) 167 { 168 case WM_INITDIALOG: 169 hMainWnd = hDlg; 170 171 uXIcon = GetSystemMetrics(SM_CXSMICON); 172 uYIcon = GetSystemMetrics(SM_CYSMICON); 173 174 SetDialogIcon(hDlg); 175 176 return OnCreate(hDlg); 177 178 case WM_SETTINGCHANGE: 179 uXIconNew = GetSystemMetrics(SM_CXSMICON); 180 uYIconNew = GetSystemMetrics(SM_CYSMICON); 181 182 if ((uXIcon != uXIconNew) || (uYIcon != uYIconNew)) 183 { 184 uXIcon = uXIconNew; 185 uYIcon = uYIconNew; 186 SetDialogIcon(hDlg); 187 } 188 break; 189 190 case WM_COMMAND: 191 192 if (LOWORD(wParam) == IDOK) 193 { 194 //MsConfig_OnSaveChanges(); 195 } 196 197 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { 198 EndDialog(hDlg, LOWORD(wParam)); 199 return TRUE; 200 } 201 break; 202 203 case WM_NOTIFY: 204 pnmh = (LPNMHDR)lParam; 205 if ((pnmh->hwndFrom == hTabWnd) && 206 (pnmh->idFrom == IDC_TAB) && 207 (pnmh->code == TCN_SELCHANGE)) 208 { 209 MsConfig_OnTabWndSelChange(); 210 } 211 break; 212 213 case WM_SYSCOLORCHANGE: 214 /* Forward WM_SYSCOLORCHANGE to common controls */ 215 SendMessage(hServicesListCtrl, WM_SYSCOLORCHANGE, 0, 0); 216 SendMessage(hStartupListCtrl, WM_SYSCOLORCHANGE, 0, 0); 217 SendMessage(hToolsListCtrl, WM_SYSCOLORCHANGE, 0, 0); 218 break; 219 220 case WM_DESTROY: 221 if (hToolsPage) 222 DestroyWindow(hToolsPage); 223 if (hGeneralPage) 224 DestroyWindow(hGeneralPage); 225 if (hServicesPage) 226 DestroyWindow(hServicesPage); 227 if (hStartupPage) 228 DestroyWindow(hStartupPage); 229 if (hFreeLdrPage) 230 DestroyWindow(hFreeLdrPage); 231 if (hSystemPage) 232 DestroyWindow(hSystemPage); 233 if (hDialogIcon) 234 DestroyIcon(hDialogIcon); 235 return DefWindowProc(hDlg, message, wParam, lParam); 236 } 237 238 return 0; 239 } 240 241 int APIENTRY _tWinMain(HINSTANCE hInstance, 242 HINSTANCE hPrevInstance, 243 LPTSTR lpCmdLine, 244 int nCmdShow) 245 { 246 247 INITCOMMONCONTROLSEX InitControls; 248 249 UNREFERENCED_PARAMETER(hPrevInstance); 250 UNREFERENCED_PARAMETER(lpCmdLine); 251 UNREFERENCED_PARAMETER(nCmdShow); 252 253 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX); 254 InitControls.dwICC = ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES; 255 InitCommonControlsEx(&InitControls); 256 257 hInst = hInstance; 258 259 DialogBox(hInst, (LPCTSTR)IDD_MSCONFIG_DIALOG, NULL, MsConfigWndProc); 260 261 return 0; 262 } 263 264 /* EOF */ 265