ReactOS 0.4.15-dev-8434-g155a7c7
CStartMenuBtnCtxMenu Class Reference
Inheritance diagram for CStartMenuBtnCtxMenu:
Collaboration diagram for CStartMenuBtnCtxMenu:

Public Member Functions

HRESULT Initialize (ITrayWindow *pTrayWnd, IN HWND hWndOwner)
 
virtual HRESULT STDMETHODCALLTYPE QueryContextMenu (HMENU hPopup, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT STDMETHODCALLTYPE InvokeCommand (LPCMINVOKECOMMANDINFO lpici)
 
virtual HRESULT STDMETHODCALLTYPE GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
 
 CStartMenuBtnCtxMenu ()
 
virtual ~CStartMenuBtnCtxMenu ()
 
- 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 ()
 
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 ()
 

Private Types

enum  { INNERIDOFFSET = ID_SHELL_CMD_LAST + 1 }
 

Private Member Functions

HRESULT CreateContextMenuFromShellFolderPidl (HMENU hPopup, UINT idCmdFirst, UINT idCmdLast)
 
VOID AddStartContextMenuItems (IN HMENU hPopup)
 

Static Private Member Functions

static BOOL IsShellCmdId (UINT_PTR id)
 

Private Attributes

CComPtr< ITrayWindow > m_TrayWnd
 
CComPtr< IContextMenum_Inner
 
CComPtr< IShellFolderm_Folder
 
HWND m_Owner
 
LPITEMIDLIST m_FolderPidl
 

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
 
- Static Public Member Functions inherited from ATL::CComCoClass< CStartMenuBtnCtxMenu >
static LPCTSTR WINAPI GetObjectDescription ()
 
- 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)
 
- 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 27 of file startctxmnu.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
INNERIDOFFSET 

Definition at line 36 of file startctxmnu.cpp.

#define ID_SHELL_CMD_LAST
Definition: resource.h:218

Constructor & Destructor Documentation

◆ CStartMenuBtnCtxMenu()

CStartMenuBtnCtxMenu::CStartMenuBtnCtxMenu ( )
inline

Definition at line 234 of file startctxmnu.cpp.

235 {
236 }

◆ ~CStartMenuBtnCtxMenu()

virtual CStartMenuBtnCtxMenu::~CStartMenuBtnCtxMenu ( )
inlinevirtual

Definition at line 238 of file startctxmnu.cpp.

239 {
240 if (m_FolderPidl)
242 }
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:44
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:940

Member Function Documentation

◆ AddStartContextMenuItems()

VOID CStartMenuBtnCtxMenu::AddStartContextMenuItems ( IN HMENU  hPopup)
inlineprivate

Definition at line 71 of file startctxmnu.cpp.

72 {
73 WCHAR szBuf[MAX_PATH];
74 HRESULT hRet;
76 /* If this ever asserts, let m_Inner use 1..ID_SHELL_CMD_FIRST-1 instead */
77 C_ASSERT(ID_SHELL_CMD_LAST < 0xffff / 2);
78
79 /* Add the "Open All Users" menu item */
82 szBuf,
83 _countof(szBuf)))
84 {
85 AppendMenu(hPopup,
88 szBuf);
89 }
90
92 {
93 /* Check if we should add menu items for the common start menu */
96 NULL,
98 szBuf);
99 if (SUCCEEDED(hRet) && hRet != S_FALSE)
100 {
101 /* The directory exists, but only show the items if the
102 user can actually make any changes to the common start
103 menu. This is most likely only the case if the user
104 has administrative rights! */
105 if (IsUserAnAdmin())
106 {
107 AppendMenu(hPopup,
109 0,
110 NULL);
111
112 /* Add the "Open All Users" menu item */
115 szBuf,
116 _countof(szBuf)))
117 {
118 AppendMenu(hPopup,
119 MF_STRING,
121 szBuf);
122 }
123
124 /* Add the "Explore All Users" menu item */
127 szBuf,
128 _countof(szBuf)))
129 {
130 AppendMenu(hPopup,
131 MF_STRING,
133 szBuf);
134 }
135 }
136 }
137 }
138 }
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
#define IDS_PROPERTIES
Definition: resource.h:102
#define ID_SHELL_CMD_PROPERTIES
Definition: resource.h:204
#define ID_SHELL_CMD_FIRST
Definition: resource.h:217
#define IDS_EXPLORE_ALL_USERS
Definition: resource.h:101
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
Definition: resource.h:206
#define IDS_OPEN_ALL_USERS
Definition: resource.h:100
#define ID_SHELL_CMD_OPEN_ALL_USERS
Definition: resource.h:205
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define C_ASSERT(e)
Definition: intsafe.h:73
#define SHGetFolderPath
Definition: shlobj.h:2170
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2193
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2148
BOOL WINAPI IsUserAnAdmin(void)
Definition: shellord.c:2802
@ REST_NOCOMMONGROUPS
Definition: shlobj.h:1664
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
#define _countof(array)
Definition: sndvol32.h:70
#define S_FALSE
Definition: winerror.h:2357
#define AppendMenu
Definition: winuser.h:5740
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MF_STRING
Definition: winuser.h:138
#define MF_SEPARATOR
Definition: winuser.h:137
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by QueryContextMenu().

◆ CreateContextMenuFromShellFolderPidl()

HRESULT CStartMenuBtnCtxMenu::CreateContextMenuFromShellFolderPidl ( HMENU  hPopup,
UINT  idCmdFirst,
UINT  idCmdLast 
)
inlineprivate

Definition at line 46 of file startctxmnu.cpp.

47 {
48 HRESULT hRet;
49
51 if (SUCCEEDED(hRet))
52 {
53 if (hPopup != NULL)
54 {
55 hRet = m_Inner->QueryContextMenu(
56 hPopup,
57 0,
58 idCmdFirst,
59 idCmdLast,
60 CMF_VERBSONLY);
61
62 if (SUCCEEDED(hRet))
63 {
64 return hRet;
65 }
66 }
67 }
68 return E_FAIL;
69 }
CComPtr< IShellFolder > m_Folder
Definition: startctxmnu.cpp:41
CComPtr< IContextMenu > m_Inner
Definition: startctxmnu.cpp:40
#define E_FAIL
Definition: ddrawi.h:102
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_NULL_PPV_ARG(Itype, ppType)

Referenced by QueryContextMenu().

◆ GetCommandString()

virtual HRESULT STDMETHODCALLTYPE CStartMenuBtnCtxMenu::GetCommandString ( UINT_PTR  idCmd,
UINT  uType,
UINT pwReserved,
LPSTR  pszName,
UINT  cchMax 
)
inlinevirtual

Implements IContextMenu.

Definition at line 223 of file startctxmnu.cpp.

228 {
229 if (!IsShellCmdId(idCmd) && m_Inner)
230 return m_Inner->GetCommandString(idCmd, uType, pwReserved, pszName, cchMax);
231 return E_NOTIMPL;
232 }
UINT cchMax
static BOOL IsShellCmdId(UINT_PTR id)
Definition: startctxmnu.cpp:37
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Initialize()

HRESULT CStartMenuBtnCtxMenu::Initialize ( ITrayWindow *  pTrayWnd,
IN HWND  hWndOwner 
)
inline

Definition at line 141 of file startctxmnu.cpp.

142 {
143 m_TrayWnd = pTrayWnd;
144 m_Owner = hWndOwner;
145 return S_OK;
146 }
CComPtr< ITrayWindow > m_TrayWnd
Definition: startctxmnu.cpp:39
#define S_OK
Definition: intsafe.h:52

◆ InvokeCommand()

virtual HRESULT STDMETHODCALLTYPE CStartMenuBtnCtxMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
inlinevirtual

Implements IContextMenu.

Definition at line 193 of file startctxmnu.cpp.

194 {
195 UINT uiCmdId = PtrToUlong(lpici->lpVerb);
196 if (!IsShellCmdId((UINT_PTR)lpici->lpVerb))
197 {
198 CMINVOKECOMMANDINFO cmici = { 0 };
199 CHAR szDir[MAX_PATH];
200
201 /* Setup and invoke the shell command */
202 cmici.cbSize = sizeof(cmici);
203 cmici.hwnd = m_Owner;
204 if (IS_INTRESOURCE(lpici->lpVerb))
205 cmici.lpVerb = MAKEINTRESOURCEA(uiCmdId - INNERIDOFFSET);
206 else
207 cmici.lpVerb = lpici->lpVerb;
208 cmici.nShow = SW_NORMAL;
209
210 /* FIXME: Support Unicode!!! */
212 {
213 cmici.lpDirectory = szDir;
214 }
215
216 return m_Inner->InvokeCommand(&cmici);
217 }
218 m_TrayWnd->ExecContextMenuCmd(uiCmdId);
219 return S_OK;
220 }
#define PtrToUlong(u)
Definition: config.h:107
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
Definition: pidl.c:1280
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define SW_NORMAL
Definition: winuser.h:769
char CHAR
Definition: xmlstorage.h:175

◆ IsShellCmdId()

static BOOL CStartMenuBtnCtxMenu::IsShellCmdId ( UINT_PTR  id)
inlinestaticprivate

Definition at line 37 of file startctxmnu.cpp.

37{ return id < INNERIDOFFSET; }

Referenced by GetCommandString(), and InvokeCommand().

◆ QueryContextMenu()

virtual HRESULT STDMETHODCALLTYPE CStartMenuBtnCtxMenu::QueryContextMenu ( HMENU  hPopup,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
inlinevirtual

Implements IContextMenu.

Definition at line 149 of file startctxmnu.cpp.

154 {
155 LPITEMIDLIST pidlStart;
156 CComPtr<IShellFolder> psfDesktop;
157 HRESULT hRet = S_OK;
158 UINT idInnerFirst = idCmdFirst + INNERIDOFFSET;
159
160 psfDesktop = NULL;
161 m_Inner = NULL;
162
164 if (pidlStart != NULL)
165 {
166 m_FolderPidl = ILClone(ILFindLastID(pidlStart));
167 ILRemoveLastID(pidlStart);
168
169 if (m_FolderPidl != NULL)
170 {
171 hRet = SHGetDesktopFolder(&psfDesktop);
172 if (SUCCEEDED(hRet))
173 {
174 hRet = psfDesktop->BindToObject(pidlStart, NULL, IID_PPV_ARG(IShellFolder, &m_Folder));
175 if (SUCCEEDED(hRet))
176 {
177 hRet = CreateContextMenuFromShellFolderPidl(hPopup, idInnerFirst, idCmdLast);
178 }
179 }
180 }
181
182 ILFree(pidlStart);
183 }
184 if (idCmdLast - idCmdFirst >= ID_SHELL_CMD_LAST - ID_SHELL_CMD_FIRST)
185 {
187 hRet = SUCCEEDED(hRet) ? hRet + idInnerFirst : idInnerFirst;
188 }
189 return hRet;
190 }
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT CreateContextMenuFromShellFolderPidl(HMENU hPopup, UINT idCmdFirst, UINT idCmdLast)
Definition: startctxmnu.cpp:46
VOID AddStartContextMenuItems(IN HMENU hPopup)
Definition: startctxmnu.cpp:71
#define TRUE
Definition: types.h:120
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:443
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:221
#define CSIDL_STARTMENU
Definition: shlobj.h:2183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define IID_PPV_ARG(Itype, ppType)

Member Data Documentation

◆ m_Folder

CComPtr<IShellFolder> CStartMenuBtnCtxMenu::m_Folder
private

Definition at line 41 of file startctxmnu.cpp.

Referenced by CreateContextMenuFromShellFolderPidl(), and QueryContextMenu().

◆ m_FolderPidl

LPITEMIDLIST CStartMenuBtnCtxMenu::m_FolderPidl
private

◆ m_Inner

CComPtr<IContextMenu> CStartMenuBtnCtxMenu::m_Inner
private

◆ m_Owner

HWND CStartMenuBtnCtxMenu::m_Owner
private

◆ m_TrayWnd

CComPtr<ITrayWindow> CStartMenuBtnCtxMenu::m_TrayWnd
private

Definition at line 39 of file startctxmnu.cpp.

Referenced by Initialize(), and InvokeCommand().


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