1 /* 2 * ReactOS Explorer 3 * 4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org> 5 * 2015 Robert Naumann <gonzomdx@gmail.com> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #include "precomp.h" 23 24 typedef struct _PROPSHEET_INFO 25 { 26 HWND hTaskbarWnd; 27 HWND hStartWnd; 28 29 HBITMAP hTaskbarBitmap; 30 HBITMAP hTrayBitmap; 31 HBITMAP hStartBitmap; 32 } PROPSHEET_INFO, *PPROPSHEET_INFO; 33 34 35 static BOOL 36 UpdateBitmaps(PPROPSHEET_INFO pPropInfo) 37 { 38 HWND hwndLock, hwndHide, hwndGroup, hwndShowQL, hwndClock, hwndSeconds, hwndHideInactive, hwndModernStart, hwndClassicStart; 39 HWND hwndTaskbarBitmap, hwndTrayBitmap, hwndStartBitmap; 40 HWND hwndCustomizeNotifyButton, hwndCustomizeClassicStartButton, hwndCustomizeModernStartButton; 41 BOOL bLock, bHide, bGroup, bShowQL, bShowClock, bShowSeconds, bHideInactive; 42 LPTSTR lpTaskBarImageName = NULL, lpTrayImageName = NULL, lpStartImageName = NULL; 43 BOOL bRet = FALSE; 44 45 hwndLock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_LOCK); 46 hwndHide = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDE); 47 hwndGroup = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_GROUP); 48 hwndShowQL = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SHOWQL); 49 50 hwndClock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_CLOCK); 51 hwndSeconds = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SECONDS); 52 hwndHideInactive = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDEICONS); 53 54 hwndCustomizeNotifyButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_ICONCUST); 55 56 hwndModernStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENU); 57 hwndClassicStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENUCLASSIC); 58 59 hwndCustomizeClassicStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCLASSICCUST); 60 hwndCustomizeModernStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCUST); 61 62 63 64 if (hwndLock && hwndHide && hwndGroup && hwndShowQL && hwndClock && hwndSeconds && hwndHideInactive) 65 { 66 bLock = (SendMessage(hwndLock, BM_GETCHECK, 0, 0) == BST_CHECKED); 67 bHide = (SendMessage(hwndHide, BM_GETCHECK, 0, 0) == BST_CHECKED); 68 bGroup = (SendMessage(hwndGroup, BM_GETCHECK, 0, 0) == BST_CHECKED); 69 bShowQL = (SendMessage(hwndShowQL, BM_GETCHECK, 0, 0) == BST_CHECKED); 70 71 bShowClock = (SendMessage(hwndClock, BM_GETCHECK, 0, 0) == BST_CHECKED); 72 bShowSeconds = (SendMessage(hwndSeconds, BM_GETCHECK, 0, 0) == BST_CHECKED); 73 bHideInactive = (SendMessage(hwndHideInactive, BM_GETCHECK, 0, 0) == BST_CHECKED); 74 75 if (bHide) 76 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_AUTOHIDE); 77 else if (bLock && bGroup && bShowQL) 78 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_QL); 79 else if (bLock && !bGroup && !bShowQL) 80 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_NOQL); 81 else if (bLock && bGroup && !bShowQL) 82 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_NOQL); 83 else if (bLock && !bGroup && bShowQL) 84 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_QL); 85 else if (!bLock && !bGroup && !bShowQL) 86 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL); 87 else if (!bLock && bGroup && !bShowQL) 88 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_NOQL); 89 else if (!bLock && !bGroup && bShowQL) 90 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_QL); 91 else if (!bLock && bGroup && bShowQL) 92 lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_QL); 93 94 95 if (lpTaskBarImageName) 96 { 97 if (pPropInfo->hTaskbarBitmap) 98 { 99 DeleteObject(pPropInfo->hTaskbarBitmap); 100 } 101 102 pPropInfo->hTaskbarBitmap = (HBITMAP)LoadImageW(hExplorerInstance, 103 lpTaskBarImageName, 104 IMAGE_BITMAP, 105 0, 106 0, 107 LR_DEFAULTCOLOR); 108 if (pPropInfo->hTaskbarBitmap) 109 { 110 hwndTaskbarBitmap = GetDlgItem(pPropInfo->hTaskbarWnd, 111 IDC_TASKBARPROP_TASKBARBITMAP); 112 if (hwndTaskbarBitmap) 113 { 114 BITMAP bm; 115 GetObject(pPropInfo->hTaskbarBitmap, sizeof(bm), &bm); 116 SetWindowPos(hwndTaskbarBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, 117 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 118 SendMessage(hwndTaskbarBitmap, 119 STM_SETIMAGE, 120 IMAGE_BITMAP, 121 (LPARAM)pPropInfo->hTaskbarBitmap); 122 } 123 } 124 } 125 126 if (bHideInactive) 127 { 128 EnableWindow(hwndCustomizeNotifyButton, TRUE); 129 if (bShowClock) 130 { 131 EnableWindow(hwndSeconds, TRUE); 132 if (bShowSeconds) 133 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_SECONDS); 134 else 135 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_CLOCK); 136 } 137 else 138 { 139 SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0); 140 EnableWindow(hwndSeconds, FALSE); 141 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_NOCLOCK); 142 } 143 } 144 else 145 { 146 EnableWindow(hwndCustomizeNotifyButton, FALSE); 147 if (bShowClock) 148 { 149 EnableWindow(hwndSeconds, TRUE); 150 if (bShowSeconds) 151 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_SECONDS); 152 else 153 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_CLOCK); 154 } 155 else 156 { 157 SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0); 158 EnableWindow(hwndSeconds, FALSE); 159 lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_NOCLOCK); 160 } 161 } 162 163 if (lpTrayImageName) 164 { 165 if (pPropInfo->hTrayBitmap) 166 { 167 DeleteObject(pPropInfo->hTrayBitmap); 168 } 169 170 pPropInfo->hTrayBitmap = (HBITMAP)LoadImageW(hExplorerInstance, 171 lpTrayImageName, 172 IMAGE_BITMAP, 173 0, 174 0, 175 LR_DEFAULTCOLOR); 176 if (pPropInfo->hTrayBitmap) 177 { 178 hwndTrayBitmap = GetDlgItem(pPropInfo->hTaskbarWnd, 179 IDC_TASKBARPROP_NOTIFICATIONBITMAP); 180 if (hwndTrayBitmap) 181 { 182 BITMAP bm; 183 GetObject(pPropInfo->hTrayBitmap, sizeof(bm), &bm); 184 SetWindowPos(hwndTrayBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, 185 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 186 SendMessage(hwndTrayBitmap, 187 STM_SETIMAGE, 188 IMAGE_BITMAP, 189 (LPARAM)pPropInfo->hTrayBitmap); 190 } 191 } 192 } 193 } 194 195 if(hwndClassicStart && hwndModernStart) 196 { 197 if(SendMessage(hwndModernStart, BM_GETCHECK, 0, 0) == BST_CHECKED) 198 { 199 EnableWindow(hwndCustomizeModernStartButton, TRUE); 200 EnableWindow(hwndCustomizeClassicStartButton, FALSE); 201 lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW); 202 } 203 else 204 { 205 EnableWindow(hwndCustomizeModernStartButton, FALSE); 206 EnableWindow(hwndCustomizeClassicStartButton, TRUE); 207 lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW_CLASSIC); 208 } 209 210 if (lpStartImageName) 211 { 212 if (pPropInfo->hStartBitmap) 213 { 214 DeleteObject(pPropInfo->hStartBitmap); 215 } 216 217 pPropInfo->hStartBitmap = (HBITMAP)LoadImageW(hExplorerInstance, 218 lpStartImageName, 219 IMAGE_BITMAP, 220 0, 221 0, 222 LR_DEFAULTCOLOR); 223 if (pPropInfo->hStartBitmap) 224 { 225 hwndStartBitmap = GetDlgItem(pPropInfo->hStartWnd, 226 IDC_TASKBARPROP_STARTMENU_BITMAP); 227 if (hwndStartBitmap) 228 { 229 BITMAP bm; 230 GetObject(pPropInfo->hStartBitmap, sizeof(bm), &bm); 231 SetWindowPos(hwndStartBitmap, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2, 232 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 233 SendMessage(hwndStartBitmap, 234 STM_SETIMAGE, 235 IMAGE_BITMAP, 236 (LPARAM)pPropInfo->hStartBitmap); 237 } 238 } 239 } 240 } 241 242 return bRet; 243 } 244 245 static VOID 246 OnCreateTaskbarPage(HWND hwnd, 247 PPROPSHEET_INFO pPropInfo) 248 { 249 SetWindowLongPtr(hwnd, 250 GWLP_USERDATA, 251 (LONG_PTR)pPropInfo); 252 253 pPropInfo->hTaskbarWnd = hwnd; 254 255 CheckDlgButton(hwnd, IDC_TASKBARPROP_LOCK, TaskBarSettings.bLock ? BST_CHECKED : BST_UNCHECKED); 256 CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDE, TaskBarSettings.bAutoHide ? BST_CHECKED : BST_UNCHECKED); 257 CheckDlgButton(hwnd, IDC_TASKBARPROP_ONTOP, TaskBarSettings.bAlwaysOnTop ? BST_CHECKED : BST_UNCHECKED); 258 CheckDlgButton(hwnd, IDC_TASKBARPROP_GROUP, TaskBarSettings.bGroupButtons ? BST_CHECKED : BST_UNCHECKED); 259 CheckDlgButton(hwnd, IDC_TASKBARPROP_SHOWQL, TaskBarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED); 260 CheckDlgButton(hwnd, IDC_TASKBARPROP_CLOCK, TaskBarSettings.bShowClock ? BST_CHECKED : BST_UNCHECKED); 261 CheckDlgButton(hwnd, IDC_TASKBARPROP_SECONDS, TaskBarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED); 262 CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDEICONS, TaskBarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED); 263 264 UpdateBitmaps(pPropInfo); 265 } 266 267 static VOID 268 OnCreateStartPage(HWND hwnd, 269 PPROPSHEET_INFO pPropInfo) 270 { 271 pPropInfo->hStartWnd = hwnd; 272 273 CheckDlgButton(hwnd, IDC_TASKBARPROP_STARTMENUCLASSIC, 1); // HACK: This has to be read from registry! 274 275 UpdateBitmaps(pPropInfo); 276 } 277 278 INT_PTR CALLBACK 279 TaskbarPageProc(HWND hwndDlg, 280 UINT uMsg, 281 WPARAM wParam, 282 LPARAM lParam) 283 { 284 PPROPSHEET_INFO pPropInfo; 285 286 /* Get the window context */ 287 pPropInfo = (PPROPSHEET_INFO)GetWindowLongPtrW(hwndDlg, 288 GWLP_USERDATA); 289 if (pPropInfo == NULL && uMsg != WM_INITDIALOG) 290 { 291 goto HandleDefaultMessage; 292 } 293 294 switch (uMsg) 295 { 296 case WM_INITDIALOG: 297 OnCreateTaskbarPage(hwndDlg, (PPROPSHEET_INFO)((LPPROPSHEETPAGE)lParam)->lParam); 298 break; 299 300 case WM_COMMAND: 301 switch (LOWORD(wParam)) 302 { 303 case IDC_TASKBARPROP_LOCK: 304 case IDC_TASKBARPROP_HIDE: 305 case IDC_TASKBARPROP_GROUP: 306 case IDC_TASKBARPROP_SHOWQL: 307 case IDC_TASKBARPROP_HIDEICONS: 308 case IDC_TASKBARPROP_CLOCK: 309 case IDC_TASKBARPROP_SECONDS: 310 if (HIWORD(wParam) == BN_CLICKED) 311 { 312 UpdateBitmaps(pPropInfo); 313 314 /* Enable the 'Apply' button */ 315 PropSheet_Changed(GetParent(hwndDlg), hwndDlg); 316 } 317 break; 318 case IDC_TASKBARPROP_ICONCUST: 319 ShowCustomizeNotifyIcons(hExplorerInstance, hwndDlg); 320 break; 321 } 322 break; 323 324 case WM_NOTIFY: 325 { 326 LPNMHDR pnmh = (LPNMHDR)lParam; 327 328 switch (pnmh->code) 329 { 330 case PSN_SETACTIVE: 331 break; 332 333 case PSN_APPLY: 334 TaskBarSettings.bLock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_LOCK); 335 TaskBarSettings.bAutoHide = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDE); 336 TaskBarSettings.bAlwaysOnTop = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_ONTOP); 337 TaskBarSettings.bGroupButtons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_GROUP); 338 TaskBarSettings.bShowQuickLaunch = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SHOWQL); 339 TaskBarSettings.bShowClock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_CLOCK); 340 TaskBarSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS); 341 TaskBarSettings.bHideInactiveIcons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDEICONS); 342 SaveTaskBarSettings(); 343 break; 344 } 345 346 break; 347 } 348 349 case WM_DESTROY: 350 if (pPropInfo->hTaskbarBitmap) 351 { 352 DeleteObject(pPropInfo->hTaskbarBitmap); 353 } 354 if (pPropInfo->hTrayBitmap) 355 { 356 DeleteObject(pPropInfo->hTrayBitmap); 357 } 358 break; 359 360 HandleDefaultMessage: 361 default: 362 return FALSE; 363 } 364 365 return FALSE; 366 } 367 368 static INT_PTR CALLBACK 369 StartMenuPageProc(HWND hwndDlg, 370 UINT uMsg, 371 WPARAM wParam, 372 LPARAM lParam) 373 { 374 switch (uMsg) 375 { 376 case WM_INITDIALOG: 377 OnCreateStartPage(hwndDlg, (PPROPSHEET_INFO)((LPPROPSHEETPAGE)lParam)->lParam); 378 break; 379 380 case WM_COMMAND: 381 { 382 switch (LOWORD(wParam)) 383 { 384 case IDC_TASKBARPROP_STARTMENUCLASSICCUST: 385 ShowCustomizeClassic(hExplorerInstance, hwndDlg); 386 break; 387 } 388 break; 389 } 390 391 case WM_DESTROY: 392 break; 393 394 case WM_NOTIFY: 395 { 396 LPNMHDR pnmh = (LPNMHDR)lParam; 397 398 switch (pnmh->code) 399 { 400 case PSN_SETACTIVE: 401 break; 402 403 case PSN_APPLY: 404 break; 405 } 406 407 break; 408 } 409 } 410 411 return FALSE; 412 } 413 414 static VOID 415 InitPropSheetPage(PROPSHEETPAGE *psp, 416 WORD idDlg, 417 DLGPROC DlgProc, 418 LPARAM lParam) 419 { 420 ZeroMemory(psp, sizeof(*psp)); 421 psp->dwSize = sizeof(*psp); 422 psp->dwFlags = PSP_DEFAULT; 423 psp->hInstance = hExplorerInstance; 424 psp->pszTemplate = MAKEINTRESOURCEW(idDlg); 425 psp->lParam = lParam; 426 psp->pfnDlgProc = DlgProc; 427 } 428 429 430 VOID 431 DisplayTrayProperties(IN HWND hwndOwner) 432 { 433 PROPSHEET_INFO propInfo = {0}; 434 PROPSHEETHEADER psh; 435 PROPSHEETPAGE psp[2]; 436 WCHAR szCaption[256]; 437 438 if (!LoadStringW(hExplorerInstance, 439 IDS_TASKBAR_STARTMENU_PROP_CAPTION, 440 szCaption, 441 _countof(szCaption))) 442 { 443 return; 444 } 445 446 ZeroMemory(&psh, sizeof(psh)); 447 psh.dwSize = sizeof(psh); 448 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE; 449 psh.hwndParent = hwndOwner; 450 psh.hInstance = hExplorerInstance; 451 psh.hIcon = NULL; 452 psh.pszCaption = szCaption; 453 psh.nPages = _countof(psp); 454 psh.nStartPage = 0; 455 psh.ppsp = psp; 456 457 InitPropSheetPage(&psp[0], IDD_TASKBARPROP_TASKBAR, TaskbarPageProc, (LPARAM)&propInfo); 458 InitPropSheetPage(&psp[1], IDD_TASKBARPROP_STARTMENU, StartMenuPageProc, (LPARAM)&propInfo); 459 460 PropertySheet(&psh); 461 } 462