[EXPLORER] Addendum to r74307: Fix copypasta CORE-11498
[reactos.git] / reactos / base / shell / explorer / trayprop.cpp
index f02831f..960ed34 100644 (file)
@@ -28,17 +28,18 @@ typedef struct _PROPSHEET_INFO
 
     HBITMAP hTaskbarBitmap;
     HBITMAP hTrayBitmap;
+    HBITMAP hStartBitmap;
 } PROPSHEET_INFO, *PPROPSHEET_INFO;
 
 
 static BOOL
-UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
+UpdateBitmaps(PPROPSHEET_INFO pPropInfo)
 {
-    HWND hwndLock, hwndHide, hwndGroup, hwndShowQL, hwndClock, hwndSeconds, hwndHideInactive;
-    HWND hwndTaskbarBitmap, hwndTrayBitmap;
-    HWND hwndAdvancedButton;
+    HWND hwndLock, hwndHide, hwndGroup, hwndShowQL, hwndClock, hwndSeconds, hwndHideInactive, hwndModernStart, hwndClassicStart;
+    HWND hwndTaskbarBitmap, hwndTrayBitmap, hwndStartBitmap;
+    HWND hwndCustomizeNotifyButton, hwndCustomizeClassicStartButton, hwndCustomizeModernStartButton;
     BOOL bLock, bHide, bGroup, bShowQL, bShowClock, bShowSeconds, bHideInactive;
-    LPTSTR lpTaskBarImageName = NULL, lpTrayImageName = NULL;
+    LPTSTR lpTaskBarImageName = NULL, lpTrayImageName = NULL, lpStartImageName = NULL;
     BOOL bRet = FALSE;
 
     hwndLock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_LOCK);
@@ -50,7 +51,15 @@ UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
     hwndSeconds = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SECONDS);
     hwndHideInactive = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDEICONS);
     
-    hwndAdvancedButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_ICONCUST);
+    hwndCustomizeNotifyButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_ICONCUST);
+    
+    hwndModernStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENU);
+    hwndClassicStart = GetDlgItem(pPropInfo->hStartWnd, IDC_TASKBARPROP_STARTMENUCLASSIC);
+    
+    hwndCustomizeClassicStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCLASSICCUST);
+    hwndCustomizeModernStartButton = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_STARTMENUCUST);
+    
+    
 
     if (hwndLock && hwndHide && hwndGroup && hwndShowQL && hwndClock && hwndSeconds && hwndHideInactive)
     {
@@ -64,23 +73,23 @@ UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
         bHideInactive = (SendMessage(hwndHideInactive, BM_GETCHECK, 0, 0) == BST_CHECKED);
 
         if (bHide)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_AUTOHIDE);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_AUTOHIDE);
         else if (bLock  && bGroup  && bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_GROUP_QL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_QL);
         else if (bLock  && !bGroup && !bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_NOGROUP_NOQL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_NOQL);
         else if (bLock  && bGroup  && !bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_GROUP_NOQL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_GROUP_NOQL);
         else if (bLock  && !bGroup && bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_NOGROUP_QL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_LOCK_NOGROUP_QL);
         else if (!bLock && !bGroup && !bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL);
         else if (!bLock && bGroup  && !bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_GROUP_NOQL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_NOQL);
         else if (!bLock && !bGroup && bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_NOGROUP_QL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_NOGROUP_QL);
         else if (!bLock && bGroup  && bShowQL)
-            lpTaskBarImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_GROUP_QL);
+            lpTaskBarImageName = MAKEINTRESOURCEW(IDB_TASKBARPROP_NOLOCK_GROUP_QL);
 
         
         if (lpTaskBarImageName)
@@ -90,7 +99,7 @@ UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
                 DeleteObject(pPropInfo->hTaskbarBitmap);
             }
 
-            pPropInfo->hTaskbarBitmap = (HBITMAP)LoadImage(hExplorerInstance,
+            pPropInfo->hTaskbarBitmap = (HBITMAP)LoadImageW(hExplorerInstance,
                                                   lpTaskBarImageName,
                                                   IMAGE_BITMAP,
                                                   0,
@@ -112,47 +121,49 @@ UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
         
         if (bHideInactive)
         {
-            EnableWindow(hwndAdvancedButton, TRUE);
-            if(bShowClock)
+            EnableWindow(hwndCustomizeNotifyButton, TRUE);
+            if (bShowClock)
             {
                 EnableWindow(hwndSeconds, TRUE);
-                if(bShowSeconds)
-                    lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_HIDE_SECONDS);
+                if (bShowSeconds)
+                    lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_SECONDS);
                 else
-                    lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_HIDE_CLOCK);
+                    lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_CLOCK);
             }
             else
             {
+                SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0);
                 EnableWindow(hwndSeconds, FALSE);
-                lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_HIDE_NOCLOCK);
+                lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_HIDE_NOCLOCK);
             }
         }
         else
         {
-            EnableWindow(hwndAdvancedButton, FALSE);
-            if(bShowClock)
+            EnableWindow(hwndCustomizeNotifyButton, FALSE);
+            if (bShowClock)
             {
                 EnableWindow(hwndSeconds, TRUE);
-                if(bShowSeconds)
-                    lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_SHOW_SECONDS);
+                if (bShowSeconds)
+                    lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_SECONDS);
                 else
-                    lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_SHOW_CLOCK);
+                    lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_CLOCK);
             }
             else
             {
+                SendMessage(hwndSeconds, BM_SETCHECK, BST_UNCHECKED, 0);
                 EnableWindow(hwndSeconds, FALSE);
-                lpTrayImageName = MAKEINTRESOURCE(IDB_SYSTRAYPROP_SHOW_NOCLOCK);
+                lpTrayImageName = MAKEINTRESOURCEW(IDB_SYSTRAYPROP_SHOW_NOCLOCK);
             }
         }
         
-        if(lpTrayImageName)
+        if (lpTrayImageName)
         {
             if (pPropInfo->hTrayBitmap)
             {
                 DeleteObject(pPropInfo->hTrayBitmap);
             }
 
-            pPropInfo->hTrayBitmap = (HBITMAP)LoadImage(hExplorerInstance,
+            pPropInfo->hTrayBitmap = (HBITMAP)LoadImageW(hExplorerInstance,
                                                   lpTrayImageName,
                                                   IMAGE_BITMAP,
                                                   0,
@@ -172,6 +183,49 @@ UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
             }
         }
     }
+    
+    if(hwndClassicStart && hwndModernStart)
+    {
+        if(SendMessage(hwndModernStart, BM_GETCHECK, 0, 0) == BST_CHECKED)
+        {
+            EnableWindow(hwndCustomizeModernStartButton, TRUE);
+            EnableWindow(hwndCustomizeClassicStartButton, FALSE);
+            lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW);
+        }
+        else
+        {
+            EnableWindow(hwndCustomizeModernStartButton, FALSE);
+            EnableWindow(hwndCustomizeClassicStartButton, TRUE);
+            lpStartImageName = MAKEINTRESOURCEW(IDB_STARTPREVIEW_CLASSIC);
+        }
+        
+         if (lpStartImageName)
+        {
+            if (pPropInfo->hStartBitmap)
+            {
+                DeleteObject(pPropInfo->hStartBitmap);
+            }
+
+            pPropInfo->hStartBitmap = (HBITMAP)LoadImageW(hExplorerInstance,
+                                                  lpStartImageName,
+                                                  IMAGE_BITMAP,
+                                                  0,
+                                                  0,
+                                                  LR_DEFAULTCOLOR);
+            if (pPropInfo->hStartBitmap)
+            {
+                hwndStartBitmap = GetDlgItem(pPropInfo->hStartWnd,
+                                        IDC_TASKBARPROP_STARTMENU_BITMAP);
+                if (hwndStartBitmap)
+                {
+                    SendMessage(hwndStartBitmap,
+                                STM_SETIMAGE,
+                                IMAGE_BITMAP,
+                                (LPARAM)pPropInfo->hStartBitmap);
+                }
+            }
+        }
+    }
 
     return bRet;
 }
@@ -186,10 +240,27 @@ OnCreateTaskbarPage(HWND hwnd,
 
     pPropInfo->hTaskbarWnd = hwnd;
 
-    // FIXME: check buttons
-    CheckDlgButton(hwnd, IDC_TASKBARPROP_SECONDS, AdvancedSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_LOCK, TaskBarSettings.bLock ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDE, TaskBarSettings.bAutoHide ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_ONTOP, TaskBarSettings.bAlwaysOnTop ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_GROUP, TaskBarSettings.bGroupButtons ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_SHOWQL, TaskBarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_CLOCK, TaskBarSettings.bShowClock ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_SECONDS, TaskBarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED);
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_HIDEICONS, TaskBarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED);
 
-    UpdateTaskbarBitmap(pPropInfo);
+    UpdateBitmaps(pPropInfo);
+}
+
+static VOID
+OnCreateStartPage(HWND hwnd,
+                    PPROPSHEET_INFO pPropInfo)
+{
+    pPropInfo->hStartWnd = hwnd;
+
+    CheckDlgButton(hwnd, IDC_TASKBARPROP_STARTMENUCLASSIC, 1);    // HACK: This has to be read from registry!
+    
+    UpdateBitmaps(pPropInfo);
 }
 
 INT_PTR CALLBACK
@@ -226,12 +297,15 @@ TaskbarPageProc(HWND hwndDlg,
                 case IDC_TASKBARPROP_SECONDS:
                     if (HIWORD(wParam) == BN_CLICKED)
                     {
-                        UpdateTaskbarBitmap(pPropInfo);
+                        UpdateBitmaps(pPropInfo);
 
                         /* Enable the 'Apply' button */
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
                     break;
+                case IDC_TASKBARPROP_ICONCUST:
+                    ShowCustomizeNotifyIcons(hExplorerInstance, hwndDlg);
+                    break;
             }
             break;
 
@@ -245,8 +319,8 @@ TaskbarPageProc(HWND hwndDlg,
                     break;
 
                 case PSN_APPLY:
-                    AdvancedSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS);
-                    SaveSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), AdvancedSettings.bShowSeconds);
+                    TaskBarSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS);
+                    SaveTaskBarSettings();
                     break;
             }
 
@@ -281,6 +355,7 @@ StartMenuPageProc(HWND hwndDlg,
     switch (uMsg)
     {
         case WM_INITDIALOG:
+            OnCreateStartPage(hwndDlg, (PPROPSHEET_INFO)((LPPROPSHEETPAGE)lParam)->lParam);
             break;
             
         case WM_COMMAND:
@@ -323,11 +398,11 @@ InitPropSheetPage(PROPSHEETPAGE *psp,
                   DLGPROC DlgProc,
                   LPARAM lParam)
 {
-    ZeroMemory(psp, sizeof(PROPSHEETPAGE));
-    psp->dwSize = sizeof(PROPSHEETPAGE);
+    ZeroMemory(psp, sizeof(*psp));
+    psp->dwSize = sizeof(*psp);
     psp->dwFlags = PSP_DEFAULT;
     psp->hInstance = hExplorerInstance;
-    psp->pszTemplate = MAKEINTRESOURCE(idDlg);
+    psp->pszTemplate = MAKEINTRESOURCEW(idDlg);
     psp->lParam = lParam;
     psp->pfnDlgProc = DlgProc;
 }
@@ -336,27 +411,27 @@ InitPropSheetPage(PROPSHEETPAGE *psp,
 VOID
 DisplayTrayProperties(IN HWND hwndOwner)
 {
-    PROPSHEET_INFO propInfo;
+    PROPSHEET_INFO propInfo = {0};
     PROPSHEETHEADER psh;
     PROPSHEETPAGE psp[2];
     WCHAR szCaption[256];
 
-    if (!LoadString(hExplorerInstance,
-                    IDS_TASKBAR_STARTMENU_PROP_CAPTION,
-                    szCaption,
-                    sizeof(szCaption) / sizeof(szCaption[0])))
+    if (!LoadStringW(hExplorerInstance,
+                     IDS_TASKBAR_STARTMENU_PROP_CAPTION,
+                     szCaption,
+                     _countof(szCaption)))
     {
         return;
     }
 
-    ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
-    psh.dwSize = sizeof(PROPSHEETHEADER);
+    ZeroMemory(&psh, sizeof(psh));
+    psh.dwSize = sizeof(psh);
     psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
     psh.hwndParent = hwndOwner;
     psh.hInstance = hExplorerInstance;
     psh.hIcon = NULL;
     psh.pszCaption = szCaption;
-    psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
+    psh.nPages = _countof(psp);
     psh.nStartPage = 0;
     psh.ppsp = psp;