Author: dquintana
Date: Sun Nov 2 22:26:44 2014
New Revision: 65200
URL:
http://svn.reactos.org/svn/reactos?rev=65200&view=rev
Log:
[EXPLORER-NEW]
* Refactor startmnu.cpp into three separate files. startctxmnu.cpp contains the context
menu handler for the start button, and startmnusite.cpp contains the former
IStartMenuSiteImpl, renamed to CStartMenuSite.
Added:
branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp
- copied, changed from r65199,
branches/shell-experiments/base/shell/explorer-new/startmnu.cpp
branches/shell-experiments/base/shell/explorer-new/startmnusite.cpp
- copied, changed from r65199,
branches/shell-experiments/base/shell/explorer-new/startmnu.cpp
Modified:
branches/shell-experiments/base/shell/explorer-new/CMakeLists.txt
branches/shell-experiments/base/shell/explorer-new/precomp.h
branches/shell-experiments/base/shell/explorer-new/startmnu.cpp
Modified: branches/shell-experiments/base/shell/explorer-new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/CMakeLists.txt [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/explorer-new/CMakeLists.txt [iso-8859-1] Sun Nov
2 22:26:44 2014
@@ -11,7 +11,9 @@
rshell.cpp
settings.cpp
shellservice.cpp
+ startctxmnu.cpp
startmnu.cpp
+ startmnusite.cpp
startup.cpp
taskband.cpp
taskswnd.cpp
Modified: branches/shell-experiments/base/shell/explorer-new/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/precomp.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/explorer-new/precomp.h [iso-8859-1] Sun Nov 2
22:26:44 2014
@@ -243,7 +243,7 @@
IN DWORD dwValue);
/*
- * startup.c
+ * startup.cpp
*/
int
@@ -257,7 +257,7 @@
DisplayTrayProperties(IN HWND hwndOwner);
/*
- * desktop.c
+ * desktop.cpp
*/
HANDLE
DesktopCreateWindow(IN OUT ITrayWindow *Tray);
@@ -266,7 +266,7 @@
DesktopDestroyShellWindow(IN HANDLE hDesktop);
/*
- * taskband.c
+ * taskband.cpp
*/
/* Internal Task Band CLSID */
@@ -297,7 +297,7 @@
CreateTaskBand(IN OUT ITrayWindow *Tray);
/*
- * tbsite.c
+ * tbsite.cpp
*/
#define INTERFACE ITrayBandSite
@@ -339,7 +339,7 @@
OUT HWND *phWndTaskSwitch);
/*
- * startmnu.c
+ * startmnu.cpp
*/
extern const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu;
@@ -375,6 +375,13 @@
IN BOOL bSmallIcons);
/*
+* startmnusite.cpp
+*/
+
+HRESULT
+CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
+
+/*
* trayntfy.c
*/
Copied: branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp (from r65199,
branches/shell-experiments/base/shell/explorer-new/startmnu.cpp)
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/startmnu.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp [iso-8859-1] Sun
Nov 2 22:26:44 2014
@@ -23,6 +23,8 @@
/*
* Start menu button context menu
*/
+
+// TODO: Convert into an IContextMenu
typedef struct _STARTMNU_CTMENU_CTX
{
@@ -56,7 +58,7 @@
HRESULT hRet;
HMENU hPopup;
- hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *)&pidl,
IID_NULL_PPV_ARG(IContextMenu, &pcm));
+ hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *) &pidl,
IID_NULL_PPV_ARG(IContextMenu, &pcm));
if (SUCCEEDED(hRet))
{
hPopup = CreatePopupMenu();
@@ -64,11 +66,11 @@
if (hPopup != NULL)
{
hRet = pcm->QueryContextMenu(
- hPopup,
- 0,
- ID_SHELL_CMD_FIRST,
- ID_SHELL_CMD_LAST,
- CMF_VERBSONLY);
+ hPopup,
+ 0,
+ ID_SHELL_CMD_FIRST,
+ ID_SHELL_CMD_LAST,
+ CMF_VERBSONLY);
if (SUCCEEDED(hRet))
{
@@ -95,18 +97,18 @@
{
if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <=
ID_SHELL_CMD_LAST))
{
- CMINVOKECOMMANDINFO cmici = {0};
+ CMINVOKECOMMANDINFO cmici = { 0 };
CHAR szDir[MAX_PATH];
/* Setup and invoke the shell command */
cmici.cbSize = sizeof(cmici);
cmici.hwnd = hWndOwner;
- cmici.lpVerb = (LPCSTR)MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST);
+ cmici.lpVerb = (LPCSTR) MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST);
cmici.nShow = SW_NORMAL;
/* FIXME: Support Unicode!!! */
if (SHGetPathFromIDListA(psmcmc->pidl,
- szDir))
+ szDir))
{
cmici.lpDirectory = szDir;
}
@@ -126,17 +128,16 @@
}
static VOID
-AddStartContextMenuItems(IN HWND hWndOwner,
- IN HMENU hPopup)
+AddStartContextMenuItems(IN HWND hWndOwner, IN HMENU hPopup)
{
WCHAR szBuf[MAX_PATH];
HRESULT hRet;
/* Add the "Open All Users" menu item */
if (LoadString(hExplorerInstance,
- IDS_PROPERTIES,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
+ IDS_PROPERTIES,
+ szBuf,
+ sizeof(szBuf) / sizeof(szBuf[0])))
{
AppendMenu(hPopup,
MF_STRING,
@@ -167,9 +168,9 @@
/* Add the "Open All Users" menu item */
if (LoadString(hExplorerInstance,
- IDS_OPEN_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
+ IDS_OPEN_ALL_USERS,
+ szBuf,
+ sizeof(szBuf) / sizeof(szBuf[0])))
{
AppendMenu(hPopup,
MF_STRING,
@@ -179,9 +180,9 @@
/* Add the "Explore All Users" menu item */
if (LoadString(hExplorerInstance,
- IDS_EXPLORE_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
+ IDS_EXPLORE_ALL_USERS,
+ szBuf,
+ sizeof(szBuf) / sizeof(szBuf[0])))
{
AppendMenu(hPopup,
MF_STRING,
@@ -260,537 +261,3 @@
return NULL;
}
-
-/*****************************************************************************
- ** IStartMenuSite ***********************************************************
- *****************************************************************************/
-
-class IStartMenuSiteImpl :
- public CComCoClass<IStartMenuSiteImpl>,
- public CComObjectRootEx<CComMultiThreadModelNoCS>,
- public IStartMenuSite,
- public IServiceProvider,
- public ITrayPriv,
- public IOleCommandTarget,
- public IMenuPopup
-{
- CComPtr<ITrayWindow> Tray;
- CComPtr<IMenuPopup> StartMenuPopup;
-
-public:
- IStartMenuSiteImpl()
- {
- }
-
- virtual ~IStartMenuSiteImpl() { }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE QueryService(
- IN REFGUID guidService,
- IN REFIID riid,
- OUT PVOID *ppvObject)
- {
- if (IsEqualGUID(guidService, SID_SMenuPopup))
- {
- return QueryInterface(riid, ppvObject);
- }
-
- return E_NOINTERFACE;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE GetWindow(
- OUT HWND *phwnd)
- {
- TRACE("ITrayPriv::GetWindow\n");
-
- *phwnd = Tray->GetHWND();
- if (*phwnd != NULL)
- return S_OK;
-
- return E_FAIL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(
- IN BOOL fEnterMode)
- {
- TRACE("ITrayPriv::ContextSensitiveHelp\n");
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Execute(
- IN IShellFolder *pShellFolder,
- IN LPCITEMIDLIST pidl)
- {
- HMODULE hShlwapi;
- HRESULT ret = S_FALSE;
-
- TRACE("ITrayPriv::Execute\n");
-
- hShlwapi = GetModuleHandle(TEXT("SHLWAPI.DLL"));
- if (hShlwapi != NULL)
- {
- SHINVDEFCMD SHInvokeDefCmd;
-
- /* SHInvokeDefaultCommand */
- SHInvokeDefCmd = (SHINVDEFCMD) GetProcAddress(hShlwapi,
- (LPCSTR) ((LONG) 279));
- if (SHInvokeDefCmd != NULL)
- {
- ret = SHInvokeDefCmd(Tray->GetHWND(),
- pShellFolder,
- pidl);
- }
- }
-
- return ret;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Unknown(
- IN PVOID Unknown1,
- IN PVOID Unknown2,
- IN PVOID Unknown3,
- IN PVOID Unknown4)
- {
- TRACE("ITrayPriv::Unknown(0x%p,0x%p,0x%p,0x%p)\n", Unknown1, Unknown2,
Unknown3, Unknown4);
- return E_NOTIMPL;
- }
-
- virtual BOOL
- ShowUndockMenuItem(VOID)
- {
- TRACE("ShowUndockMenuItem() not implemented!\n");
- /* FIXME: How do we detect this?! */
- return FALSE;
- }
-
- virtual BOOL
- ShowSynchronizeMenuItem(VOID)
- {
- TRACE("ShowSynchronizeMenuItem() not implemented!\n");
- /* FIXME: How do we detect this?! */
- return FALSE;
- }
-
- virtual HRESULT STDMETHODCALLTYPE AppendMenu(
- OUT HMENU* phMenu)
- {
- HMENU hMenu, hSettingsMenu;
- DWORD dwLogoff;
- BOOL bWantLogoff;
- UINT uLastItemsCount = 5; /* 5 menu items below the last separator */
- WCHAR szUser[128];
-
- TRACE("ITrayPriv::AppendMenu\n");
-
- hMenu = LoadPopupMenu(hExplorerInstance,
- MAKEINTRESOURCE(IDM_STARTMENU));
- *phMenu = hMenu;
- if (hMenu == NULL)
- return E_FAIL;
-
- /* Remove menu items that don't apply */
-
- dwLogoff = SHRestricted(REST_STARTMENULOGOFF);
- bWantLogoff = (dwLogoff == 2 ||
- SHRestricted(REST_FORCESTARTMENULOGOFF) ||
- GetExplorerRegValueSet(HKEY_CURRENT_USER,
- TEXT("Advanced"),
- TEXT("StartMenuLogoff")));
-
- /* Favorites */
- if (!GetExplorerRegValueSet(HKEY_CURRENT_USER,
- TEXT("Advanced"),
- TEXT("StartMenuFavorites")))
- {
- DeleteMenu(hMenu,
- IDM_FAVORITES,
- MF_BYCOMMAND);
- }
-
- /* Documents */
- if (SHRestricted(REST_NORECENTDOCSMENU))
- {
- DeleteMenu(hMenu,
- IDM_DOCUMENTS,
- MF_BYCOMMAND);
- }
-
- /* Settings */
- hSettingsMenu = FindSubMenu(hMenu,
- IDM_SETTINGS,
- FALSE);
- if (hSettingsMenu != NULL)
- {
- if (SHRestricted(REST_NOSETFOLDERS))
- {
- /* Control Panel */
- if (SHRestricted(REST_NOCONTROLPANEL))
- {
- DeleteMenu(hSettingsMenu,
- IDM_CONTROLPANEL,
- MF_BYCOMMAND);
-
- /* Delete the separator below it */
- DeleteMenu(hSettingsMenu,
- 0,
- MF_BYPOSITION);
- }
-
- /* Network Connections */
- if (SHRestricted(REST_NONETWORKCONNECTIONS))
- {
- DeleteMenu(hSettingsMenu,
- IDM_NETWORKCONNECTIONS,
- MF_BYCOMMAND);
- }
-
- /* Printers and Faxes */
- DeleteMenu(hSettingsMenu,
- IDM_PRINTERSANDFAXES,
- MF_BYCOMMAND);
- }
-
- /* Security */
- if (GetSystemMetrics(SM_REMOTECONTROL) == 0 ||
- SHRestricted(REST_NOSECURITY))
- {
- DeleteMenu(hSettingsMenu,
- IDM_SECURITY,
- MF_BYCOMMAND);
- }
-
- if (GetMenuItemCount(hSettingsMenu) == 0)
- {
- DeleteMenu(hMenu,
- IDM_SETTINGS,
- MF_BYCOMMAND);
- }
- }
-
- /* Search */
- /* FIXME: Enable after implementing */
- /* if (SHRestricted(REST_NOFIND)) */
- {
- DeleteMenu(hMenu,
- IDM_SEARCH,
- MF_BYCOMMAND);
- }
-
- /* FIXME: Help */
-
- /* Run */
- if (SHRestricted(REST_NORUN))
- {
- DeleteMenu(hMenu,
- IDM_RUN,
- MF_BYCOMMAND);
- }
-
- /* Synchronize */
- if (!ShowSynchronizeMenuItem())
- {
- DeleteMenu(hMenu,
- IDM_SYNCHRONIZE,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Log off */
- if (dwLogoff != 1 && bWantLogoff)
- {
- /* FIXME: We need a more sophisticated way to determine whether to show
- or hide it, it might be hidden in too many cases!!! */
-
- /* Update Log Off menu item */
- if (!GetCurrentLoggedOnUserName(szUser,
- sizeof(szUser) / sizeof(szUser[0])))
- {
- szUser[0] = _T('\0');
- }
-
- if (!FormatMenuString(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND,
- szUser))
- {
- /* We couldn't update the menu item, delete it... */
- DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
- }
- }
- else
- {
- DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
-
- /* Disconnect */
- if (GetSystemMetrics(SM_REMOTECONTROL) == 0)
- {
- DeleteMenu(hMenu,
- IDM_DISCONNECT,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Undock computer */
- if (!ShowUndockMenuItem())
- {
- DeleteMenu(hMenu,
- IDM_UNDOCKCOMPUTER,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Shut down */
- if (SHRestricted(REST_NOCLOSE))
- {
- DeleteMenu(hMenu,
- IDM_SHUTDOWN,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- if (uLastItemsCount == 0)
- {
- /* Remove the separator at the end of the menu */
- DeleteMenu(hMenu,
- IDM_LASTSTARTMENU_SEPARATOR,
- MF_BYCOMMAND);
- }
-
- return S_OK;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE QueryStatus(
- IN const GUID *pguidCmdGroup OPTIONAL,
- IN ULONG cCmds,
- IN OUT OLECMD *prgCmds,
- IN OUT OLECMDTEXT *pCmdText OPTIONAL)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Exec(
- IN const GUID *pguidCmdGroup OPTIONAL,
- IN DWORD nCmdID,
- IN DWORD nCmdExecOpt,
- IN VARIANTARG *pvaIn OPTIONAL,
- IN VARIANTARG *pvaOut OPTIONAL)
- {
- return E_NOTIMPL;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown ** ppunkClient)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet)
- {
- if (!fSet)
- {
- return Tray_OnStartMenuDismissed();
- }
-
- return S_OK;
- }
-
- /*******************************************************************/
-
- HRESULT Initialize(IN ITrayWindow *tray)
- {
- Tray = tray;
- return S_OK;
- }
-
- DECLARE_NOT_AGGREGATABLE(IStartMenuSiteImpl)
-
- DECLARE_PROTECT_FINAL_CONSTRUCT()
- BEGIN_COM_MAP(IStartMenuSiteImpl)
- COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
- COM_INTERFACE_ENTRY_IID(IID_ITrayPriv, ITrayPriv)
- COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
- COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
- COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
- END_COM_MAP()
-};
-
-HRESULT CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv)
-{
- return ShellObjectCreatorInit<IStartMenuSiteImpl>(Tray, riid, ppv);
-}
-
-HRESULT
-UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
- IN HBITMAP hbmBanner OPTIONAL,
- IN BOOL bSmallIcons)
-{
- CComPtr<IBanneredBar> pbb;
- HRESULT hRet;
-
- hRet = pMenuPopup->QueryInterface(IID_PPV_ARG(IBanneredBar, &pbb));
- if (SUCCEEDED(hRet))
- {
- hRet = pbb->SetBitmap( hbmBanner);
-
- /* Update the icon size */
- hRet = pbb->SetIconSize(bSmallIcons ? BMICON_SMALL : BMICON_LARGE);
- }
-
- return hRet;
-}
-
-IMenuPopup *
-CreateStartMenu(IN ITrayWindow *Tray,
- OUT IMenuBand **ppMenuBand,
- IN HBITMAP hbmBanner OPTIONAL,
- IN BOOL bSmallIcons)
-{
- HRESULT hr;
- IObjectWithSite *pOws = NULL;
- IMenuPopup *pMp = NULL;
- IUnknown *pSms = NULL;
- IMenuBand *pMb = NULL;
- IInitializeObject *pIo;
- IUnknown *pUnk = NULL;
- IBandSite *pBs = NULL;
- DWORD dwBandId = 0;
-
- hr = CreateStartMenuSite(Tray, IID_PPV_ARG(IUnknown, &pSms));
- if (FAILED_UNEXPECTEDLY(hr))
- return NULL;
-
-#if 0
- hr = CoCreateInstance(&CLSID_StartMenu,
- NULL,
- CLSCTX_INPROC_SERVER,
- &IID_IMenuPopup,
- (PVOID *)&pMp);
-#else
- hr = _CStartMenu_Constructor(IID_PPV_ARG(IMenuPopup, &pMp));
-#endif
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("CoCreateInstance failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pMp->QueryInterface(IID_PPV_ARG(IObjectWithSite, &pOws));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_QueryInterface failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Set the menu site so we can handle messages */
- hr = pOws->SetSite(pSms);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IObjectWithSite_SetSite failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Initialize the menu object */
- hr = pMp->QueryInterface(IID_PPV_ARG(IInitializeObject, &pIo));
- if (SUCCEEDED(hr))
- {
- hr = pIo->Initialize();
- pIo->Release();
- }
- else
- hr = S_OK;
-
- /* Everything is initialized now. Let's get the IMenuBand interface. */
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_QueryInterface failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pMp->GetClient( &pUnk);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_GetClient failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pUnk->QueryInterface(IID_PPV_ARG(IBandSite, &pBs));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IUnknown_QueryInterface pBs failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Finally we have the IBandSite interface, there's only one
- band in it that apparently provides the IMenuBand interface */
- hr = pBs->EnumBands( 0, &dwBandId);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IBandSite_EnumBands failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pBs->GetBandObject( dwBandId, IID_PPV_ARG(IMenuBand, &pMb));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IBandSite_GetBandObject failed: %x\n", hr);
- goto cleanup;
- }
-
- UpdateStartMenu(pMp,
- hbmBanner,
- bSmallIcons);
-
-cleanup:
- if (SUCCEEDED(hr))
- *ppMenuBand = pMb;
- else if (pMb != NULL)
- pMb->Release();
-
- if (pBs != NULL)
- pBs->Release();
- if (pUnk != NULL)
- pUnk->Release();
- if (pOws != NULL)
- pOws->Release();
- if (pMp != NULL)
- pMp->Release();
- if (pSms != NULL)
- pSms->Release();
-
- if (FAILED_UNEXPECTEDLY(hr))
- return NULL;
- return pMp;
-}
Modified: branches/shell-experiments/base/shell/explorer-new/startmnu.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/startmnu.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/explorer-new/startmnu.cpp [iso-8859-1] Sun Nov
2 22:26:44 2014
@@ -20,638 +20,6 @@
#include "precomp.h"
-/*
- * Start menu button context menu
- */
-
-typedef struct _STARTMNU_CTMENU_CTX
-{
- IContextMenu *pcm;
- LPITEMIDLIST pidl;
-} STARTMNU_CTMENU_CTX, *PSTARTMNU_CTMENU_CTX;
-
-static HMENU
-CreateStartContextMenu(IN HWND hWndOwner,
- IN PVOID *ppcmContext,
- IN PVOID Context OPTIONAL);
-
-static VOID
-OnStartContextMenuCommand(IN HWND hWndOwner,
- IN UINT uiCmdId,
- IN PVOID pcmContext OPTIONAL,
- IN PVOID Context OPTIONAL);
-
-const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu = {
- CreateStartContextMenu,
- OnStartContextMenuCommand
-};
-
-static HMENU
-CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
- IN OUT IShellFolder *psf,
- IN OUT LPITEMIDLIST pidl,
- OUT IContextMenu **ppcm)
-{
- CComPtr<IContextMenu> pcm;
- HRESULT hRet;
- HMENU hPopup;
-
- hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *)&pidl,
IID_NULL_PPV_ARG(IContextMenu, &pcm));
- if (SUCCEEDED(hRet))
- {
- hPopup = CreatePopupMenu();
-
- if (hPopup != NULL)
- {
- hRet = pcm->QueryContextMenu(
- hPopup,
- 0,
- ID_SHELL_CMD_FIRST,
- ID_SHELL_CMD_LAST,
- CMF_VERBSONLY);
-
- if (SUCCEEDED(hRet))
- {
- *ppcm = pcm;
- return hPopup;
- }
-
- DestroyMenu(hPopup);
- }
- }
-
- return NULL;
-}
-
-static VOID
-OnStartContextMenuCommand(IN HWND hWndOwner,
- IN UINT uiCmdId,
- IN PVOID pcmContext OPTIONAL,
- IN PVOID Context OPTIONAL)
-{
- PSTARTMNU_CTMENU_CTX psmcmc = (PSTARTMNU_CTMENU_CTX) pcmContext;
-
- if (uiCmdId != 0)
- {
- if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <=
ID_SHELL_CMD_LAST))
- {
- CMINVOKECOMMANDINFO cmici = {0};
- CHAR szDir[MAX_PATH];
-
- /* Setup and invoke the shell command */
- cmici.cbSize = sizeof(cmici);
- cmici.hwnd = hWndOwner;
- cmici.lpVerb = (LPCSTR)MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST);
- cmici.nShow = SW_NORMAL;
-
- /* FIXME: Support Unicode!!! */
- if (SHGetPathFromIDListA(psmcmc->pidl,
- szDir))
- {
- cmici.lpDirectory = szDir;
- }
-
- psmcmc->pcm->InvokeCommand(&cmici);
- }
- else
- {
- ITrayWindow * TrayWnd = (ITrayWindow *) Context;
- TrayWnd->ExecContextMenuCmd(uiCmdId);
- }
- }
-
- psmcmc->pcm->Release();
-
- HeapFree(hProcessHeap, 0, psmcmc);
-}
-
-static VOID
-AddStartContextMenuItems(IN HWND hWndOwner,
- IN HMENU hPopup)
-{
- WCHAR szBuf[MAX_PATH];
- HRESULT hRet;
-
- /* Add the "Open All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_PROPERTIES,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_PROPERTIES,
- szBuf);
- }
-
- if (!SHRestricted(REST_NOCOMMONGROUPS))
- {
- /* Check if we should add menu items for the common start menu */
- hRet = SHGetFolderPath(hWndOwner,
- CSIDL_COMMON_STARTMENU,
- NULL,
- SHGFP_TYPE_CURRENT,
- szBuf);
- if (SUCCEEDED(hRet) && hRet != S_FALSE)
- {
- /* The directory exists, but only show the items if the
- user can actually make any changes to the common start
- menu. This is most likely only the case if the user
- has administrative rights! */
- if (IsUserAnAdmin())
- {
- AppendMenu(hPopup,
- MF_SEPARATOR,
- 0,
- NULL);
-
- /* Add the "Open All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_OPEN_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_OPEN_ALL_USERS,
- szBuf);
- }
-
- /* Add the "Explore All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_EXPLORE_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_EXPLORE_ALL_USERS,
- szBuf);
- }
- }
- }
- }
-}
-
-static HMENU
-CreateStartContextMenu(IN HWND hWndOwner,
- IN PVOID *ppcmContext,
- IN PVOID Context OPTIONAL)
-{
- LPITEMIDLIST pidlStart, pidlLast;
- CComPtr<IShellFolder> psfStart;
- CComPtr<IShellFolder> psfDesktop;
- CComPtr<IContextMenu> pcm;
- HRESULT hRet;
- HMENU hPopup;
-
- pidlStart = SHCloneSpecialIDList(hWndOwner,
- CSIDL_STARTMENU,
- TRUE);
-
- if (pidlStart != NULL)
- {
- pidlLast = ILClone(ILFindLastID(pidlStart));
- ILRemoveLastID(pidlStart);
-
- if (pidlLast != NULL)
- {
- hRet = SHGetDesktopFolder(&psfDesktop);
- if (SUCCEEDED(hRet))
- {
- hRet = psfDesktop->BindToObject(pidlStart, NULL,
IID_PPV_ARG(IShellFolder, &psfStart));
- if (SUCCEEDED(hRet))
- {
- hPopup = CreateContextMenuFromShellFolderPidl(hWndOwner,
- psfStart,
- pidlLast,
- &pcm);
-
- if (hPopup != NULL)
- {
- PSTARTMNU_CTMENU_CTX psmcmc;
-
- psmcmc = (PSTARTMNU_CTMENU_CTX) HeapAlloc(hProcessHeap, 0,
sizeof(*psmcmc));
- if (psmcmc != NULL)
- {
- psmcmc->pcm = pcm;
- psmcmc->pidl = pidlLast;
-
- AddStartContextMenuItems(hWndOwner,
- hPopup);
-
- *ppcmContext = psmcmc;
- return hPopup;
- }
- else
- {
- DestroyMenu(hPopup);
- hPopup = NULL;
- }
- }
- }
- }
-
- ILFree(pidlLast);
- }
-
- ILFree(pidlStart);
- }
-
- return NULL;
-}
-
-/*****************************************************************************
- ** IStartMenuSite ***********************************************************
- *****************************************************************************/
-
-class IStartMenuSiteImpl :
- public CComCoClass<IStartMenuSiteImpl>,
- public CComObjectRootEx<CComMultiThreadModelNoCS>,
- public IStartMenuSite,
- public IServiceProvider,
- public ITrayPriv,
- public IOleCommandTarget,
- public IMenuPopup
-{
- CComPtr<ITrayWindow> Tray;
- CComPtr<IMenuPopup> StartMenuPopup;
-
-public:
- IStartMenuSiteImpl()
- {
- }
-
- virtual ~IStartMenuSiteImpl() { }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE QueryService(
- IN REFGUID guidService,
- IN REFIID riid,
- OUT PVOID *ppvObject)
- {
- if (IsEqualGUID(guidService, SID_SMenuPopup))
- {
- return QueryInterface(riid, ppvObject);
- }
-
- return E_NOINTERFACE;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE GetWindow(
- OUT HWND *phwnd)
- {
- TRACE("ITrayPriv::GetWindow\n");
-
- *phwnd = Tray->GetHWND();
- if (*phwnd != NULL)
- return S_OK;
-
- return E_FAIL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(
- IN BOOL fEnterMode)
- {
- TRACE("ITrayPriv::ContextSensitiveHelp\n");
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Execute(
- IN IShellFolder *pShellFolder,
- IN LPCITEMIDLIST pidl)
- {
- HMODULE hShlwapi;
- HRESULT ret = S_FALSE;
-
- TRACE("ITrayPriv::Execute\n");
-
- hShlwapi = GetModuleHandle(TEXT("SHLWAPI.DLL"));
- if (hShlwapi != NULL)
- {
- SHINVDEFCMD SHInvokeDefCmd;
-
- /* SHInvokeDefaultCommand */
- SHInvokeDefCmd = (SHINVDEFCMD) GetProcAddress(hShlwapi,
- (LPCSTR) ((LONG) 279));
- if (SHInvokeDefCmd != NULL)
- {
- ret = SHInvokeDefCmd(Tray->GetHWND(),
- pShellFolder,
- pidl);
- }
- }
-
- return ret;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Unknown(
- IN PVOID Unknown1,
- IN PVOID Unknown2,
- IN PVOID Unknown3,
- IN PVOID Unknown4)
- {
- TRACE("ITrayPriv::Unknown(0x%p,0x%p,0x%p,0x%p)\n", Unknown1, Unknown2,
Unknown3, Unknown4);
- return E_NOTIMPL;
- }
-
- virtual BOOL
- ShowUndockMenuItem(VOID)
- {
- TRACE("ShowUndockMenuItem() not implemented!\n");
- /* FIXME: How do we detect this?! */
- return FALSE;
- }
-
- virtual BOOL
- ShowSynchronizeMenuItem(VOID)
- {
- TRACE("ShowSynchronizeMenuItem() not implemented!\n");
- /* FIXME: How do we detect this?! */
- return FALSE;
- }
-
- virtual HRESULT STDMETHODCALLTYPE AppendMenu(
- OUT HMENU* phMenu)
- {
- HMENU hMenu, hSettingsMenu;
- DWORD dwLogoff;
- BOOL bWantLogoff;
- UINT uLastItemsCount = 5; /* 5 menu items below the last separator */
- WCHAR szUser[128];
-
- TRACE("ITrayPriv::AppendMenu\n");
-
- hMenu = LoadPopupMenu(hExplorerInstance,
- MAKEINTRESOURCE(IDM_STARTMENU));
- *phMenu = hMenu;
- if (hMenu == NULL)
- return E_FAIL;
-
- /* Remove menu items that don't apply */
-
- dwLogoff = SHRestricted(REST_STARTMENULOGOFF);
- bWantLogoff = (dwLogoff == 2 ||
- SHRestricted(REST_FORCESTARTMENULOGOFF) ||
- GetExplorerRegValueSet(HKEY_CURRENT_USER,
- TEXT("Advanced"),
- TEXT("StartMenuLogoff")));
-
- /* Favorites */
- if (!GetExplorerRegValueSet(HKEY_CURRENT_USER,
- TEXT("Advanced"),
- TEXT("StartMenuFavorites")))
- {
- DeleteMenu(hMenu,
- IDM_FAVORITES,
- MF_BYCOMMAND);
- }
-
- /* Documents */
- if (SHRestricted(REST_NORECENTDOCSMENU))
- {
- DeleteMenu(hMenu,
- IDM_DOCUMENTS,
- MF_BYCOMMAND);
- }
-
- /* Settings */
- hSettingsMenu = FindSubMenu(hMenu,
- IDM_SETTINGS,
- FALSE);
- if (hSettingsMenu != NULL)
- {
- if (SHRestricted(REST_NOSETFOLDERS))
- {
- /* Control Panel */
- if (SHRestricted(REST_NOCONTROLPANEL))
- {
- DeleteMenu(hSettingsMenu,
- IDM_CONTROLPANEL,
- MF_BYCOMMAND);
-
- /* Delete the separator below it */
- DeleteMenu(hSettingsMenu,
- 0,
- MF_BYPOSITION);
- }
-
- /* Network Connections */
- if (SHRestricted(REST_NONETWORKCONNECTIONS))
- {
- DeleteMenu(hSettingsMenu,
- IDM_NETWORKCONNECTIONS,
- MF_BYCOMMAND);
- }
-
- /* Printers and Faxes */
- DeleteMenu(hSettingsMenu,
- IDM_PRINTERSANDFAXES,
- MF_BYCOMMAND);
- }
-
- /* Security */
- if (GetSystemMetrics(SM_REMOTECONTROL) == 0 ||
- SHRestricted(REST_NOSECURITY))
- {
- DeleteMenu(hSettingsMenu,
- IDM_SECURITY,
- MF_BYCOMMAND);
- }
-
- if (GetMenuItemCount(hSettingsMenu) == 0)
- {
- DeleteMenu(hMenu,
- IDM_SETTINGS,
- MF_BYCOMMAND);
- }
- }
-
- /* Search */
- /* FIXME: Enable after implementing */
- /* if (SHRestricted(REST_NOFIND)) */
- {
- DeleteMenu(hMenu,
- IDM_SEARCH,
- MF_BYCOMMAND);
- }
-
- /* FIXME: Help */
-
- /* Run */
- if (SHRestricted(REST_NORUN))
- {
- DeleteMenu(hMenu,
- IDM_RUN,
- MF_BYCOMMAND);
- }
-
- /* Synchronize */
- if (!ShowSynchronizeMenuItem())
- {
- DeleteMenu(hMenu,
- IDM_SYNCHRONIZE,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Log off */
- if (dwLogoff != 1 && bWantLogoff)
- {
- /* FIXME: We need a more sophisticated way to determine whether to show
- or hide it, it might be hidden in too many cases!!! */
-
- /* Update Log Off menu item */
- if (!GetCurrentLoggedOnUserName(szUser,
- sizeof(szUser) / sizeof(szUser[0])))
- {
- szUser[0] = _T('\0');
- }
-
- if (!FormatMenuString(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND,
- szUser))
- {
- /* We couldn't update the menu item, delete it... */
- DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
- }
- }
- else
- {
- DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
-
- /* Disconnect */
- if (GetSystemMetrics(SM_REMOTECONTROL) == 0)
- {
- DeleteMenu(hMenu,
- IDM_DISCONNECT,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Undock computer */
- if (!ShowUndockMenuItem())
- {
- DeleteMenu(hMenu,
- IDM_UNDOCKCOMPUTER,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- /* Shut down */
- if (SHRestricted(REST_NOCLOSE))
- {
- DeleteMenu(hMenu,
- IDM_SHUTDOWN,
- MF_BYCOMMAND);
- uLastItemsCount--;
- }
-
- if (uLastItemsCount == 0)
- {
- /* Remove the separator at the end of the menu */
- DeleteMenu(hMenu,
- IDM_LASTSTARTMENU_SEPARATOR,
- MF_BYCOMMAND);
- }
-
- return S_OK;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE QueryStatus(
- IN const GUID *pguidCmdGroup OPTIONAL,
- IN ULONG cCmds,
- IN OUT OLECMD *prgCmds,
- IN OUT OLECMDTEXT *pCmdText OPTIONAL)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Exec(
- IN const GUID *pguidCmdGroup OPTIONAL,
- IN DWORD nCmdID,
- IN DWORD nCmdExecOpt,
- IN VARIANTARG *pvaIn OPTIONAL,
- IN VARIANTARG *pvaOut OPTIONAL)
- {
- return E_NOTIMPL;
- }
-
- /*******************************************************************/
-
- virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown ** ppunkClient)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(RECT *prc)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS
dwFlags)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType)
- {
- return E_NOTIMPL;
- }
-
- virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet)
- {
- if (!fSet)
- {
- return Tray_OnStartMenuDismissed();
- }
-
- return S_OK;
- }
-
- /*******************************************************************/
-
- HRESULT Initialize(IN ITrayWindow *tray)
- {
- Tray = tray;
- return S_OK;
- }
-
- DECLARE_NOT_AGGREGATABLE(IStartMenuSiteImpl)
-
- DECLARE_PROTECT_FINAL_CONSTRUCT()
- BEGIN_COM_MAP(IStartMenuSiteImpl)
- COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
- COM_INTERFACE_ENTRY_IID(IID_ITrayPriv, ITrayPriv)
- COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
- COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
- COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
- END_COM_MAP()
-};
-
-HRESULT CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv)
-{
- return ShellObjectCreatorInit<IStartMenuSiteImpl>(Tray, riid, ppv);
-}
-
HRESULT
UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
IN HBITMAP hbmBanner OPTIONAL,
@@ -663,7 +31,7 @@
hRet = pMenuPopup->QueryInterface(IID_PPV_ARG(IBanneredBar, &pbb));
if (SUCCEEDED(hRet))
{
- hRet = pbb->SetBitmap( hbmBanner);
+ hRet = pbb->SetBitmap(hbmBanner);
/* Update the icon size */
hRet = pbb->SetIconSize(bSmallIcons ? BMICON_SMALL : BMICON_LARGE);
@@ -739,7 +107,7 @@
goto cleanup;
}
- hr = pMp->GetClient( &pUnk);
+ hr = pMp->GetClient(&pUnk);
if (FAILED_UNEXPECTEDLY(hr))
{
TRACE("IMenuPopup_GetClient failed: %x\n", hr);
@@ -755,14 +123,14 @@
/* Finally we have the IBandSite interface, there's only one
band in it that apparently provides the IMenuBand interface */
- hr = pBs->EnumBands( 0, &dwBandId);
+ hr = pBs->EnumBands(0, &dwBandId);
if (FAILED_UNEXPECTEDLY(hr))
{
TRACE("IBandSite_EnumBands failed: %x\n", hr);
goto cleanup;
}
- hr = pBs->GetBandObject( dwBandId, IID_PPV_ARG(IMenuBand, &pMb));
+ hr = pBs->GetBandObject(dwBandId, IID_PPV_ARG(IMenuBand, &pMb));
if (FAILED_UNEXPECTEDLY(hr))
{
TRACE("IBandSite_GetBandObject failed: %x\n", hr);
Copied: branches/shell-experiments/base/shell/explorer-new/startmnusite.cpp (from r65199,
branches/shell-experiments/base/shell/explorer-new/startmnu.cpp)
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/startmnu.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/explorer-new/startmnusite.cpp [iso-8859-1] Sun
Nov 2 22:26:44 2014
@@ -20,253 +20,12 @@
#include "precomp.h"
-/*
- * Start menu button context menu
- */
-
-typedef struct _STARTMNU_CTMENU_CTX
-{
- IContextMenu *pcm;
- LPITEMIDLIST pidl;
-} STARTMNU_CTMENU_CTX, *PSTARTMNU_CTMENU_CTX;
-
-static HMENU
-CreateStartContextMenu(IN HWND hWndOwner,
- IN PVOID *ppcmContext,
- IN PVOID Context OPTIONAL);
-
-static VOID
-OnStartContextMenuCommand(IN HWND hWndOwner,
- IN UINT uiCmdId,
- IN PVOID pcmContext OPTIONAL,
- IN PVOID Context OPTIONAL);
-
-const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu = {
- CreateStartContextMenu,
- OnStartContextMenuCommand
-};
-
-static HMENU
-CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner,
- IN OUT IShellFolder *psf,
- IN OUT LPITEMIDLIST pidl,
- OUT IContextMenu **ppcm)
-{
- CComPtr<IContextMenu> pcm;
- HRESULT hRet;
- HMENU hPopup;
-
- hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *)&pidl,
IID_NULL_PPV_ARG(IContextMenu, &pcm));
- if (SUCCEEDED(hRet))
- {
- hPopup = CreatePopupMenu();
-
- if (hPopup != NULL)
- {
- hRet = pcm->QueryContextMenu(
- hPopup,
- 0,
- ID_SHELL_CMD_FIRST,
- ID_SHELL_CMD_LAST,
- CMF_VERBSONLY);
-
- if (SUCCEEDED(hRet))
- {
- *ppcm = pcm;
- return hPopup;
- }
-
- DestroyMenu(hPopup);
- }
- }
-
- return NULL;
-}
-
-static VOID
-OnStartContextMenuCommand(IN HWND hWndOwner,
- IN UINT uiCmdId,
- IN PVOID pcmContext OPTIONAL,
- IN PVOID Context OPTIONAL)
-{
- PSTARTMNU_CTMENU_CTX psmcmc = (PSTARTMNU_CTMENU_CTX) pcmContext;
-
- if (uiCmdId != 0)
- {
- if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <=
ID_SHELL_CMD_LAST))
- {
- CMINVOKECOMMANDINFO cmici = {0};
- CHAR szDir[MAX_PATH];
-
- /* Setup and invoke the shell command */
- cmici.cbSize = sizeof(cmici);
- cmici.hwnd = hWndOwner;
- cmici.lpVerb = (LPCSTR)MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST);
- cmici.nShow = SW_NORMAL;
-
- /* FIXME: Support Unicode!!! */
- if (SHGetPathFromIDListA(psmcmc->pidl,
- szDir))
- {
- cmici.lpDirectory = szDir;
- }
-
- psmcmc->pcm->InvokeCommand(&cmici);
- }
- else
- {
- ITrayWindow * TrayWnd = (ITrayWindow *) Context;
- TrayWnd->ExecContextMenuCmd(uiCmdId);
- }
- }
-
- psmcmc->pcm->Release();
-
- HeapFree(hProcessHeap, 0, psmcmc);
-}
-
-static VOID
-AddStartContextMenuItems(IN HWND hWndOwner,
- IN HMENU hPopup)
-{
- WCHAR szBuf[MAX_PATH];
- HRESULT hRet;
-
- /* Add the "Open All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_PROPERTIES,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_PROPERTIES,
- szBuf);
- }
-
- if (!SHRestricted(REST_NOCOMMONGROUPS))
- {
- /* Check if we should add menu items for the common start menu */
- hRet = SHGetFolderPath(hWndOwner,
- CSIDL_COMMON_STARTMENU,
- NULL,
- SHGFP_TYPE_CURRENT,
- szBuf);
- if (SUCCEEDED(hRet) && hRet != S_FALSE)
- {
- /* The directory exists, but only show the items if the
- user can actually make any changes to the common start
- menu. This is most likely only the case if the user
- has administrative rights! */
- if (IsUserAnAdmin())
- {
- AppendMenu(hPopup,
- MF_SEPARATOR,
- 0,
- NULL);
-
- /* Add the "Open All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_OPEN_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_OPEN_ALL_USERS,
- szBuf);
- }
-
- /* Add the "Explore All Users" menu item */
- if (LoadString(hExplorerInstance,
- IDS_EXPLORE_ALL_USERS,
- szBuf,
- sizeof(szBuf) / sizeof(szBuf[0])))
- {
- AppendMenu(hPopup,
- MF_STRING,
- ID_SHELL_CMD_EXPLORE_ALL_USERS,
- szBuf);
- }
- }
- }
- }
-}
-
-static HMENU
-CreateStartContextMenu(IN HWND hWndOwner,
- IN PVOID *ppcmContext,
- IN PVOID Context OPTIONAL)
-{
- LPITEMIDLIST pidlStart, pidlLast;
- CComPtr<IShellFolder> psfStart;
- CComPtr<IShellFolder> psfDesktop;
- CComPtr<IContextMenu> pcm;
- HRESULT hRet;
- HMENU hPopup;
-
- pidlStart = SHCloneSpecialIDList(hWndOwner,
- CSIDL_STARTMENU,
- TRUE);
-
- if (pidlStart != NULL)
- {
- pidlLast = ILClone(ILFindLastID(pidlStart));
- ILRemoveLastID(pidlStart);
-
- if (pidlLast != NULL)
- {
- hRet = SHGetDesktopFolder(&psfDesktop);
- if (SUCCEEDED(hRet))
- {
- hRet = psfDesktop->BindToObject(pidlStart, NULL,
IID_PPV_ARG(IShellFolder, &psfStart));
- if (SUCCEEDED(hRet))
- {
- hPopup = CreateContextMenuFromShellFolderPidl(hWndOwner,
- psfStart,
- pidlLast,
- &pcm);
-
- if (hPopup != NULL)
- {
- PSTARTMNU_CTMENU_CTX psmcmc;
-
- psmcmc = (PSTARTMNU_CTMENU_CTX) HeapAlloc(hProcessHeap, 0,
sizeof(*psmcmc));
- if (psmcmc != NULL)
- {
- psmcmc->pcm = pcm;
- psmcmc->pidl = pidlLast;
-
- AddStartContextMenuItems(hWndOwner,
- hPopup);
-
- *ppcmContext = psmcmc;
- return hPopup;
- }
- else
- {
- DestroyMenu(hPopup);
- hPopup = NULL;
- }
- }
- }
- }
-
- ILFree(pidlLast);
- }
-
- ILFree(pidlStart);
- }
-
- return NULL;
-}
-
/*****************************************************************************
** IStartMenuSite ***********************************************************
*****************************************************************************/
-class IStartMenuSiteImpl :
- public CComCoClass<IStartMenuSiteImpl>,
+class CStartMenuSite :
+ public CComCoClass<CStartMenuSite>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public IStartMenuSite,
public IServiceProvider,
@@ -278,11 +37,11 @@
CComPtr<IMenuPopup> StartMenuPopup;
public:
- IStartMenuSiteImpl()
- {
- }
-
- virtual ~IStartMenuSiteImpl() { }
+ CStartMenuSite()
+ {
+ }
+
+ virtual ~CStartMenuSite() {}
/*******************************************************************/
@@ -336,12 +95,12 @@
/* SHInvokeDefaultCommand */
SHInvokeDefCmd = (SHINVDEFCMD) GetProcAddress(hShlwapi,
- (LPCSTR) ((LONG) 279));
+ (LPCSTR) ((LONG) 279));
if (SHInvokeDefCmd != NULL)
{
ret = SHInvokeDefCmd(Tray->GetHWND(),
- pShellFolder,
- pidl);
+ pShellFolder,
+ pidl);
}
}
@@ -386,7 +145,7 @@
TRACE("ITrayPriv::AppendMenu\n");
hMenu = LoadPopupMenu(hExplorerInstance,
- MAKEINTRESOURCE(IDM_STARTMENU));
+ MAKEINTRESOURCE(IDM_STARTMENU));
*phMenu = hMenu;
if (hMenu == NULL)
return E_FAIL;
@@ -395,10 +154,10 @@
dwLogoff = SHRestricted(REST_STARTMENULOGOFF);
bWantLogoff = (dwLogoff == 2 ||
- SHRestricted(REST_FORCESTARTMENULOGOFF) ||
- GetExplorerRegValueSet(HKEY_CURRENT_USER,
- TEXT("Advanced"),
- TEXT("StartMenuLogoff")));
+ SHRestricted(REST_FORCESTARTMENULOGOFF) ||
+ GetExplorerRegValueSet(HKEY_CURRENT_USER,
+ TEXT("Advanced"),
+ TEXT("StartMenuLogoff")));
/* Favorites */
if (!GetExplorerRegValueSet(HKEY_CURRENT_USER,
@@ -406,22 +165,22 @@
TEXT("StartMenuFavorites")))
{
DeleteMenu(hMenu,
- IDM_FAVORITES,
- MF_BYCOMMAND);
+ IDM_FAVORITES,
+ MF_BYCOMMAND);
}
/* Documents */
if (SHRestricted(REST_NORECENTDOCSMENU))
{
DeleteMenu(hMenu,
- IDM_DOCUMENTS,
- MF_BYCOMMAND);
+ IDM_DOCUMENTS,
+ MF_BYCOMMAND);
}
/* Settings */
hSettingsMenu = FindSubMenu(hMenu,
- IDM_SETTINGS,
- FALSE);
+ IDM_SETTINGS,
+ FALSE);
if (hSettingsMenu != NULL)
{
if (SHRestricted(REST_NOSETFOLDERS))
@@ -430,27 +189,27 @@
if (SHRestricted(REST_NOCONTROLPANEL))
{
DeleteMenu(hSettingsMenu,
- IDM_CONTROLPANEL,
- MF_BYCOMMAND);
+ IDM_CONTROLPANEL,
+ MF_BYCOMMAND);
/* Delete the separator below it */
DeleteMenu(hSettingsMenu,
- 0,
- MF_BYPOSITION);
+ 0,
+ MF_BYPOSITION);
}
/* Network Connections */
if (SHRestricted(REST_NONETWORKCONNECTIONS))
{
DeleteMenu(hSettingsMenu,
- IDM_NETWORKCONNECTIONS,
- MF_BYCOMMAND);
+ IDM_NETWORKCONNECTIONS,
+ MF_BYCOMMAND);
}
/* Printers and Faxes */
DeleteMenu(hSettingsMenu,
- IDM_PRINTERSANDFAXES,
- MF_BYCOMMAND);
+ IDM_PRINTERSANDFAXES,
+ MF_BYCOMMAND);
}
/* Security */
@@ -458,15 +217,15 @@
SHRestricted(REST_NOSECURITY))
{
DeleteMenu(hSettingsMenu,
- IDM_SECURITY,
- MF_BYCOMMAND);
+ IDM_SECURITY,
+ MF_BYCOMMAND);
}
if (GetMenuItemCount(hSettingsMenu) == 0)
{
DeleteMenu(hMenu,
- IDM_SETTINGS,
- MF_BYCOMMAND);
+ IDM_SETTINGS,
+ MF_BYCOMMAND);
}
}
@@ -475,8 +234,8 @@
/* if (SHRestricted(REST_NOFIND)) */
{
DeleteMenu(hMenu,
- IDM_SEARCH,
- MF_BYCOMMAND);
+ IDM_SEARCH,
+ MF_BYCOMMAND);
}
/* FIXME: Help */
@@ -485,16 +244,16 @@
if (SHRestricted(REST_NORUN))
{
DeleteMenu(hMenu,
- IDM_RUN,
- MF_BYCOMMAND);
+ IDM_RUN,
+ MF_BYCOMMAND);
}
/* Synchronize */
if (!ShowSynchronizeMenuItem())
{
DeleteMenu(hMenu,
- IDM_SYNCHRONIZE,
- MF_BYCOMMAND);
+ IDM_SYNCHRONIZE,
+ MF_BYCOMMAND);
uLastItemsCount--;
}
@@ -518,15 +277,15 @@
{
/* We couldn't update the menu item, delete it... */
DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
+ IDM_LOGOFF,
+ MF_BYCOMMAND);
}
}
else
{
DeleteMenu(hMenu,
- IDM_LOGOFF,
- MF_BYCOMMAND);
+ IDM_LOGOFF,
+ MF_BYCOMMAND);
uLastItemsCount--;
}
@@ -535,8 +294,8 @@
if (GetSystemMetrics(SM_REMOTECONTROL) == 0)
{
DeleteMenu(hMenu,
- IDM_DISCONNECT,
- MF_BYCOMMAND);
+ IDM_DISCONNECT,
+ MF_BYCOMMAND);
uLastItemsCount--;
}
@@ -544,8 +303,8 @@
if (!ShowUndockMenuItem())
{
DeleteMenu(hMenu,
- IDM_UNDOCKCOMPUTER,
- MF_BYCOMMAND);
+ IDM_UNDOCKCOMPUTER,
+ MF_BYCOMMAND);
uLastItemsCount--;
}
@@ -553,8 +312,8 @@
if (SHRestricted(REST_NOCLOSE))
{
DeleteMenu(hMenu,
- IDM_SHUTDOWN,
- MF_BYCOMMAND);
+ IDM_SHUTDOWN,
+ MF_BYCOMMAND);
uLastItemsCount--;
}
@@ -562,8 +321,8 @@
{
/* Remove the separator at the end of the menu */
DeleteMenu(hMenu,
- IDM_LASTSTARTMENU_SEPARATOR,
- MF_BYCOMMAND);
+ IDM_LASTSTARTMENU_SEPARATOR,
+ MF_BYCOMMAND);
}
return S_OK;
@@ -635,10 +394,10 @@
return S_OK;
}
- DECLARE_NOT_AGGREGATABLE(IStartMenuSiteImpl)
+ DECLARE_NOT_AGGREGATABLE(CStartMenuSite)
DECLARE_PROTECT_FINAL_CONSTRUCT()
- BEGIN_COM_MAP(IStartMenuSiteImpl)
+ BEGIN_COM_MAP(CStartMenuSite)
COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
COM_INTERFACE_ENTRY_IID(IID_ITrayPriv, ITrayPriv)
COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
@@ -649,148 +408,5 @@
HRESULT CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv)
{
- return ShellObjectCreatorInit<IStartMenuSiteImpl>(Tray, riid, ppv);
+ return ShellObjectCreatorInit<CStartMenuSite>(Tray, riid, ppv);
}
-
-HRESULT
-UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
- IN HBITMAP hbmBanner OPTIONAL,
- IN BOOL bSmallIcons)
-{
- CComPtr<IBanneredBar> pbb;
- HRESULT hRet;
-
- hRet = pMenuPopup->QueryInterface(IID_PPV_ARG(IBanneredBar, &pbb));
- if (SUCCEEDED(hRet))
- {
- hRet = pbb->SetBitmap( hbmBanner);
-
- /* Update the icon size */
- hRet = pbb->SetIconSize(bSmallIcons ? BMICON_SMALL : BMICON_LARGE);
- }
-
- return hRet;
-}
-
-IMenuPopup *
-CreateStartMenu(IN ITrayWindow *Tray,
- OUT IMenuBand **ppMenuBand,
- IN HBITMAP hbmBanner OPTIONAL,
- IN BOOL bSmallIcons)
-{
- HRESULT hr;
- IObjectWithSite *pOws = NULL;
- IMenuPopup *pMp = NULL;
- IUnknown *pSms = NULL;
- IMenuBand *pMb = NULL;
- IInitializeObject *pIo;
- IUnknown *pUnk = NULL;
- IBandSite *pBs = NULL;
- DWORD dwBandId = 0;
-
- hr = CreateStartMenuSite(Tray, IID_PPV_ARG(IUnknown, &pSms));
- if (FAILED_UNEXPECTEDLY(hr))
- return NULL;
-
-#if 0
- hr = CoCreateInstance(&CLSID_StartMenu,
- NULL,
- CLSCTX_INPROC_SERVER,
- &IID_IMenuPopup,
- (PVOID *)&pMp);
-#else
- hr = _CStartMenu_Constructor(IID_PPV_ARG(IMenuPopup, &pMp));
-#endif
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("CoCreateInstance failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pMp->QueryInterface(IID_PPV_ARG(IObjectWithSite, &pOws));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_QueryInterface failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Set the menu site so we can handle messages */
- hr = pOws->SetSite(pSms);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IObjectWithSite_SetSite failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Initialize the menu object */
- hr = pMp->QueryInterface(IID_PPV_ARG(IInitializeObject, &pIo));
- if (SUCCEEDED(hr))
- {
- hr = pIo->Initialize();
- pIo->Release();
- }
- else
- hr = S_OK;
-
- /* Everything is initialized now. Let's get the IMenuBand interface. */
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_QueryInterface failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pMp->GetClient( &pUnk);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IMenuPopup_GetClient failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pUnk->QueryInterface(IID_PPV_ARG(IBandSite, &pBs));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IUnknown_QueryInterface pBs failed: %x\n", hr);
- goto cleanup;
- }
-
- /* Finally we have the IBandSite interface, there's only one
- band in it that apparently provides the IMenuBand interface */
- hr = pBs->EnumBands( 0, &dwBandId);
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IBandSite_EnumBands failed: %x\n", hr);
- goto cleanup;
- }
-
- hr = pBs->GetBandObject( dwBandId, IID_PPV_ARG(IMenuBand, &pMb));
- if (FAILED_UNEXPECTEDLY(hr))
- {
- TRACE("IBandSite_GetBandObject failed: %x\n", hr);
- goto cleanup;
- }
-
- UpdateStartMenu(pMp,
- hbmBanner,
- bSmallIcons);
-
-cleanup:
- if (SUCCEEDED(hr))
- *ppMenuBand = pMb;
- else if (pMb != NULL)
- pMb->Release();
-
- if (pBs != NULL)
- pBs->Release();
- if (pUnk != NULL)
- pUnk->Release();
- if (pOws != NULL)
- pOws->Release();
- if (pMp != NULL)
- pMp->Release();
- if (pSms != NULL)
- pSms->Release();
-
- if (FAILED_UNEXPECTEDLY(hr))
- return NULL;
- return pMp;
-}