ReactOS 0.4.16-dev-1386-g6ed46ba
CFindFolderContextMenu Class Reference
Inheritance diagram for CFindFolderContextMenu:
Collaboration diagram for CFindFolderContextMenu:

Public Member Functions

 ~CFindFolderContextMenu ()
 
HRESULT QueryContextMenu ([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
 
HRESULT InvokeCommand ([in] LPCMINVOKECOMMANDINFO lpici)
 
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IObjectWithSite
HRESULT SetSite ([in] IUnknown *pUnkSite)
 
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Static Public Member Functions

static HRESULT Create (IShellFolderView *pShellFolderView, UINT cidl, IContextMenu *pInnerContextMenu, IContextMenu **pContextMenu)
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Private Member Functions

STDMETHODIMP QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
STDMETHODIMP InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
 
STDMETHODIMP GetCommandString (UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
 
STDMETHODIMP SetSite (IUnknown *pUnkSite) override
 
STDMETHODIMP GetSite (REFIID riid, void **ppvSite) override
 

Private Attributes

CComPtr< IContextMenum_pInner
 
CComPtr< IShellFolderView > m_shellFolderView
 
IUnknownm_pUnkSite = NULL
 
UINT m_cidl
 
UINT m_MyFirstId = 0
 

Static Private Attributes

static const UINT ADDITIONAL_MENU_ITEMS = 2
 

Additional Inherited Members

- Public Types inherited from IContextMenu
typedef IContextMenuLPCONTEXTMENU
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Static Public Attributes inherited from IContextMenu
static const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 950 of file CFindFolder.cpp.

Constructor & Destructor Documentation

◆ ~CFindFolderContextMenu()

CFindFolderContextMenu::~CFindFolderContextMenu ( )
inline

Definition at line 1045 of file CFindFolder.cpp.

1046 {
1047 SetSite(NULL);
1048 }
STDMETHODIMP SetSite(IUnknown *pUnkSite) override
#define NULL
Definition: types.h:112

Member Function Documentation

◆ Create()

static HRESULT CFindFolderContextMenu::Create ( IShellFolderView *  pShellFolderView,
UINT  cidl,
IContextMenu pInnerContextMenu,
IContextMenu **  pContextMenu 
)
inlinestatic

Definition at line 1050 of file CFindFolder.cpp.

1051 {
1054 if (FAILED_UNEXPECTEDLY(hResult))
1055 return hResult;
1056 pObj->m_shellFolderView = pShellFolderView;
1057 pObj->m_pInner = pInnerContextMenu;
1058 pObj->m_cidl = cidl;
1059 return pObj->QueryInterface(IID_PPV_ARG(IContextMenu, pContextMenu));
1060 }
static HRESULT WINAPI CreateInstance(CComObject< Base > **pp)
Definition: atlcom.h:171
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
Definition: atlcom.h:166
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
#define IID_PPV_ARG(Itype, ppType)

Referenced by CFindFolder::GetUIObjectOf().

◆ GetCommandString()

STDMETHODIMP CFindFolderContextMenu::GetCommandString ( UINT_PTR  idCommand,
UINT  uFlags,
UINT lpReserved,
LPSTR  lpszName,
UINT  uMaxNameLen 
)
inlineprivate

Implements IContextMenu.

Definition at line 1025 of file CFindFolder.cpp.

1026 {
1027 return m_pInner->GetCommandString(idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
1028 }
CComPtr< IContextMenu > m_pInner
UINT uFlags
Definition: api.c:59
_In_ DWORD _In_ int _In_ int _In_opt_ LPNLSVERSIONINFO _In_opt_ LPVOID lpReserved
Definition: winnls.h:1199

◆ GetSite()

STDMETHODIMP CFindFolderContextMenu::GetSite ( REFIID  riid,
void **  ppvSite 
)
inlineoverrideprivate

Definition at line 1038 of file CFindFolder.cpp.

1039 {
1040 *ppvSite = NULL;
1041 return m_pUnkSite ? m_pUnkSite->QueryInterface(riid, ppvSite) : E_FAIL;
1042 }
#define E_FAIL
Definition: ddrawi.h:102
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

◆ InvokeCommand()

STDMETHODIMP CFindFolderContextMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
inlineprivate

Implements IContextMenu.

Definition at line 983 of file CFindFolder.cpp.

984 {
985 WORD idCmd = IS_INTRESOURCE(lpcmi->lpVerb) ? LOWORD(lpcmi->lpVerb) : 0;
986 if (m_MyFirstId && idCmd >= m_MyFirstId && idCmd < m_MyFirstId + ADDITIONAL_MENU_ITEMS)
987 {
988 PCUITEMID_CHILD *apidl;
989 UINT cidl;
990 HRESULT hResult = m_shellFolderView->GetSelectedObjects(&apidl, &cidl);
991 if (FAILED_UNEXPECTEDLY(hResult))
992 return hResult;
993
994 for (UINT i = 0; i < cidl; i++)
995 {
997 if (!folderPidl)
998 {
999 hResult = E_OUTOFMEMORY;
1000 break;
1001 }
1003 SHOpenFolderAndSelectItems(folderPidl, 1, &child, 0);
1004 }
1005 LocalFree(apidl); // Yes, LocalFree
1006 return hResult;
1007 }
1008
1009 // TODO: Use GetDfmCmd instead after moving all of this to shell32
1010 CHAR szVerb[42];
1011 PCSTR pszVerb = !idCmd ? lpcmi->lpVerb : NULL;
1012 if (!pszVerb && SUCCEEDED(GetCommandStringA(m_pInner, LOWORD(lpcmi->lpVerb), GCS_VERBA, szVerb, _countof(szVerb))))
1013 pszVerb = szVerb;
1014
1015 if (pszVerb && !lstrcmpiA(pszVerb, "rename"))
1016 {
1017 // Note: We can't invoke m_pInner (CDefaultContextMenu::DoRename) because the pidl is incorrect and SelectItem will fail.
1019 }
1020
1021 // FIXME: We can't block FCIDM_SHVIEW_REFRESH here, add items on SFVM_LISTREFRESHED instead
1022 return m_pInner->InvokeCommand(lpcmi);
1023 }
static HRESULT GetCommandStringA(_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
Definition: CFindFolder.cpp:25
static HRESULT BeginRenameOfShellViewSelection(IUnknown *pUnkSite)
static LPCWSTR _ILGetPath(LPCITEMIDLIST pidl)
static LPCITEMIDLIST _ILGetFSPidl(LPCITEMIDLIST pidl)
static const UINT ADDITIONAL_MENU_ITEMS
CComPtr< IShellFolderView > m_shellFolderView
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4227
#define IS_INTRESOURCE(x)
Definition: loader.c:613
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static HWND child
Definition: cursoricon.c:298
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1102
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
Definition: shlfolder.cpp:551
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
const char * PCSTR
Definition: typedefs.h:52
char CHAR
Definition: xmlstorage.h:175

◆ QueryContextMenu()

STDMETHODIMP CFindFolderContextMenu::QueryContextMenu ( HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
inlineprivate

Implements IContextMenu.

Definition at line 963 of file CFindFolder.cpp.

964 {
965 if (m_cidl > 1)
966 uFlags &= ~CMF_CANRENAME;
967
968 m_MyFirstId = 0;
969 if (idCmdLast - idCmdFirst > ADDITIONAL_MENU_ITEMS)
970 {
971 // We use the last available id. For DefView, this places us at
972 // DVIDM_CONTEXTMENU_LAST which should not collide with anything.
973 // This is just a temporary fix until we are moved to shell32 and
974 // can use DFM_MERGECONTEXTMENU.
975 _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdLast--, MFT_STRING,
977 _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdLast--, MFT_SEPARATOR, NULL, 0);
978 m_MyFirstId = idCmdLast + 1;
979 }
980 return m_pInner->QueryContextMenu(hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
981 }
static void WINAPI _InsertMenuItemW(HMENU hMenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
Definition: CFindFolder.cpp:68
#define TRUE
Definition: types.h:120
#define IDS_SEARCH_OPEN_FOLDER
Definition: resource.h:181
#define MFT_SEPARATOR
Definition: winuser.h:755
#define MFS_ENABLED
Definition: winuser.h:761
#define MFT_STRING
Definition: winuser.h:757
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ SetSite()

STDMETHODIMP CFindFolderContextMenu::SetSite ( IUnknown pUnkSite)
inlineoverrideprivate

Implements IObjectWithSite.

Definition at line 1031 of file CFindFolder.cpp.

1032 {
1033 IUnknown_Set(&m_pUnkSite, pUnkSite);
1034 IUnknown_SetSite(m_pInner, pUnkSite);
1035 return S_OK;
1036 }
VOID WINAPI IUnknown_Set(IUnknown **lppDest, IUnknown *lpUnknown)
Definition: ordinal.c:2190
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1411
#define S_OK
Definition: intsafe.h:52

Referenced by ~CFindFolderContextMenu().

Member Data Documentation

◆ ADDITIONAL_MENU_ITEMS

const UINT CFindFolderContextMenu::ADDITIONAL_MENU_ITEMS = 2
staticprivate

Definition at line 960 of file CFindFolder.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_cidl

UINT CFindFolderContextMenu::m_cidl
private

Definition at line 958 of file CFindFolder.cpp.

Referenced by QueryContextMenu().

◆ m_MyFirstId

UINT CFindFolderContextMenu::m_MyFirstId = 0
private

Definition at line 959 of file CFindFolder.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_pInner

CComPtr<IContextMenu> CFindFolderContextMenu::m_pInner
private

Definition at line 955 of file CFindFolder.cpp.

Referenced by GetCommandString(), InvokeCommand(), QueryContextMenu(), and SetSite().

◆ m_pUnkSite

IUnknown* CFindFolderContextMenu::m_pUnkSite = NULL
private

Definition at line 957 of file CFindFolder.cpp.

Referenced by GetSite(), InvokeCommand(), and SetSite().

◆ m_shellFolderView

CComPtr<IShellFolderView> CFindFolderContextMenu::m_shellFolderView
private

Definition at line 956 of file CFindFolder.cpp.

Referenced by InvokeCommand().


The documentation for this class was generated from the following file: