[explorer_new]
[reactos.git] / base / shell / explorer-new / startmnu.c
index d18b261..ae8ac01 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <precomp.h>
+#include "precomp.h"
 
 /*
  * Start menu button context menu
@@ -59,10 +59,10 @@ CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
     hRet = IShellFolder_GetUIObjectOf(psf,
                                       hWndOwner,
                                       1,
-                                      (LPCITEMIDLIST*)&pidl, /* FIXME: shouldn't need a typecast! */
+                                      (LPCITEMIDLIST *)&pidl,
                                       &IID_IContextMenu,
                                       NULL,
-                                      (PVOID*)&pcm);
+                                      (PVOID *)&pcm);
     if (SUCCEEDED(hRet))
     {
         hPopup = CreatePopupMenu();
@@ -82,9 +82,10 @@ CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
                 return hPopup;
             }
 
-            IContextMenu_Release(pcm);
             DestroyMenu(hPopup);
         }
+
+        IContextMenu_Release(pcm);
     }
 
     return NULL;
@@ -96,7 +97,7 @@ OnStartContextMenuCommand(IN HWND hWndOwner,
                           IN PVOID pcmContext  OPTIONAL,
                           IN PVOID Context  OPTIONAL)
 {
-    PSTARTMNU_CTMENU_CTX psmcmc = (PSTARTMNU_CTMENU_CTX)pcmContext;
+    PSTARTMNU_CTMENU_CTX psmcmc = pcmContext;
 
     if (uiCmdId != 0)
     {
@@ -231,7 +232,7 @@ CreateStartContextMenu(IN HWND hWndOwner,
                 hRet = IShellFolder_BindToObject(psfDesktop,
                                                  pidlStart,
                                                  NULL,
-                                                 (REFIID)&IID_IShellFolder, /* FIXME: Shouldn't require a typecast */
+                                                 &IID_IShellFolder,
                                                  (PVOID*)&psfStart);
                 if (SUCCEEDED(hRet))
                 {
@@ -255,7 +256,7 @@ CreateStartContextMenu(IN HWND hWndOwner,
                             AddStartContextMenuItems(hWndOwner,
                                                      hPopup);
 
-                            *((PSTARTMNU_CTMENU_CTX*)ppcmContext) = psmcmc;
+                            *ppcmContext = psmcmc;
                             return hPopup;
                         }
                         else
@@ -551,7 +552,15 @@ IStartMenuSiteImpl_AppendMenu(IN OUT ITrayPriv *iface,
                                           TEXT("Advanced"),
                                           TEXT("StartMenuLogoff")));
 
-    /* FIXME: Favorites */
+    /* Favorites */
+    if (!GetExplorerRegValueSet(HKEY_CURRENT_USER,
+                                TEXT("Advanced"),
+                                TEXT("StartMenuFavorites")))
+    {
+        DeleteMenu(hMenu,
+                   IDM_FAVORITES,
+                   MF_BYCOMMAND);
+    }
 
     /* Documents */
     if (SHRestricted(REST_NORECENTDOCSMENU))
@@ -772,14 +781,11 @@ IStartMenuSiteImpl_Construct(IN ITrayWindow *Tray)
     IStartMenuSiteImpl *This;
 
     This = HeapAlloc(hProcessHeap,
-                     0,
+                     HEAP_ZERO_MEMORY,
                      sizeof(*This));
     if (This == NULL)
         return NULL;
 
-    ZeroMemory(This,
-               sizeof(*This));
-
     This->lpVtbl = &IStartMenuSiteImpl_Vtbl;
     This->lpServiceProviderVtbl = &IServiceProviderImpl_Vtbl;
     This->lpStartMenuCallbackVtbl = &ITrayPrivImpl_Vtbl;
@@ -815,12 +821,11 @@ UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
 
     hRet = IMenuPopup_QueryInterface(pMenuPopup,
                                      &IID_IBanneredBar,
-                                     (PVOID)&pbb);
+                                     (PVOID *)&pbb);
     if (SUCCEEDED(hRet))
     {
         hRet = IBanneredBar_SetBitmap(pbb, hbmBanner);
 
-
         /* Update the icon size */
         hRet = IBanneredBar_SetIconSize(pbb,
                                         bSmallIcons ? BMICON_SMALL : BMICON_LARGE);
@@ -831,7 +836,7 @@ UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
     return hRet;
 }
 
-IMenuPopup*
+IMenuPopup *
 CreateStartMenu(IN ITrayWindow *Tray,
                 OUT IMenuBand **ppMenuBand,
                 IN HBITMAP hbmBanner  OPTIONAL,
@@ -851,11 +856,15 @@ CreateStartMenu(IN ITrayWindow *Tray,
     if (pSms == NULL)
         return NULL;
 
+#if 0
     hr = CoCreateInstance(&CLSID_StartMenu,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           &IID_IMenuPopup,
-                          (PVOID*)&pMp);
+                          (PVOID *)&pMp);
+#else
+    hr = CStartMenu_Constructor(&IID_IMenuPopup,(PVOID *)&pMp);
+#endif
     if (FAILED(hr))
     {
         DbgPrint("CoCreateInstance failed: %x\n", hr);
@@ -864,7 +873,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
 
     hr = IMenuPopup_QueryInterface(pMp,
                                    &IID_IObjectWithSite,
-                                   (PVOID*)&pOws);
+                                   (PVOID *)&pOws);
     if (FAILED(hr))
     {
         DbgPrint("IMenuPopup_QueryInterface failed: %x\n", hr);
@@ -872,7 +881,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
     }
 
     /* Set the menu site so we can handle messages */
-    hr = IObjectWithSite_SetSite(pOws, (IUnknown*)pSms);
+    hr = IObjectWithSite_SetSite(pOws, (IUnknown *)pSms);
     if (FAILED(hr))
     {
         DbgPrint("IObjectWithSite_SetSite failed: %x\n", hr);
@@ -903,7 +912,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
         goto cleanup;
     }
 
-    hr = IUnknown_QueryInterface(pUnk, &IID_IBandSite, (PVOID*)&pBs);
+    hr = IUnknown_QueryInterface(pUnk, &IID_IBandSite, (PVOID *)&pBs);
     if (FAILED(hr))
     {
         DbgPrint("IUnknown_QueryInterface pBs failed: %x\n", hr);
@@ -919,7 +928,7 @@ CreateStartMenu(IN ITrayWindow *Tray,
         goto cleanup;
     }
 
-    hr = IBandSite_GetBandObject(pBs, dwBandId, &IID_IMenuBand, (PVOID*)&pMb);
+    hr = IBandSite_GetBandObject(pBs, dwBandId, &IID_IMenuBand, (PVOID *)&pMb);
     if (FAILED(hr))
     {
         DbgPrint("IBandSite_GetBandObject failed: %x\n", hr);