ReactOS 0.4.16-dev-835-gd769f56
CStartMenuBtnCtxMenu Class Reference
Inheritance diagram for CStartMenuBtnCtxMenu:
Collaboration diagram for CStartMenuBtnCtxMenu:

Public Member Functions

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

Constructor & Destructor Documentation

◆ CStartMenuBtnCtxMenu()

CStartMenuBtnCtxMenu::CStartMenuBtnCtxMenu ( )
inline

Definition at line 245 of file startctxmnu.cpp.

246 {
247 }

◆ ~CStartMenuBtnCtxMenu()

virtual CStartMenuBtnCtxMenu::~CStartMenuBtnCtxMenu ( )
inlinevirtual

Definition at line 249 of file startctxmnu.cpp.

250 {
251 if (m_FolderPidl)
253 }
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:44
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044

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:108
#define ID_SHELL_CMD_PROPERTIES
Definition: resource.h:211
#define ID_SHELL_CMD_FIRST
Definition: resource.h:224
#define IDS_EXPLORE_ALL_USERS
Definition: resource.h:107
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
Definition: resource.h:213
#define IDS_OPEN_ALL_USERS
Definition: resource.h:106
#define ID_SHELL_CMD_OPEN_ALL_USERS
Definition: resource.h:212
#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:2171
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2194
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2149
BOOL WINAPI IsUserAnAdmin(void)
Definition: shellord.c:2807
@ REST_NOCOMMONGROUPS
Definition: shlobj.h:1665
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:5743
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()

STDMETHODIMP CStartMenuBtnCtxMenu::GetCommandString ( UINT_PTR  idCmd,
UINT  uType,
UINT pwReserved,
LPSTR  pszName,
UINT  cchMax 
)
inlineoverride

Implements IContextMenu.

Definition at line 233 of file startctxmnu.cpp.

239 {
240 if (!IsShellCmdId(idCmd) && m_Inner)
241 return m_Inner->GetCommandString(idCmd, uType, pwReserved, pszName, cchMax);
242 return E_NOTIMPL;
243 }
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()

STDMETHODIMP CStartMenuBtnCtxMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
inlineoverride

Implements IContextMenu.

Definition at line 193 of file startctxmnu.cpp.

194 {
195 UINT uiCmdId = PtrToUlong(lpici->lpVerb);
196 if (!IsShellCmdId(uiCmdId))
197 {
198 CMINVOKECOMMANDINFOEX cmici = { sizeof(cmici) };
199
200 /* Setup and invoke the shell command */
201 cmici.hwnd = m_Owner;
202 cmici.nShow = SW_NORMAL;
203 cmici.fMask = CMIC_MASK_UNICODE;
204 WCHAR szVerbW[MAX_PATH];
205 if (IS_INTRESOURCE(lpici->lpVerb))
206 {
207 cmici.lpVerb = MAKEINTRESOURCEA(uiCmdId - INNERIDOFFSET);
208 cmici.lpVerbW = MAKEINTRESOURCEW(uiCmdId - INNERIDOFFSET);
209 }
210 else
211 {
212 cmici.lpVerb = lpici->lpVerb;
213 SHAnsiToUnicode(lpici->lpVerb, szVerbW, _countof(szVerbW));
214 cmici.lpVerbW = szVerbW;
215 }
216
217 CHAR szDirA[MAX_PATH];
218 WCHAR szDirW[MAX_PATH];
220 {
221 SHUnicodeToAnsi(szDirW, szDirA, _countof(szDirA));
222 cmici.lpDirectory = szDirA;
223 cmici.lpDirectoryW = szDirW;
224 }
225
226 return m_Inner->InvokeCommand((LPCMINVOKECOMMANDINFO)&cmici);
227 }
228 m_TrayWnd->ExecContextMenuCmd(uiCmdId);
229 return S_OK;
230 }
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2797
#define PtrToUlong(u)
Definition: config.h:107
struct IContextMenu::tagCMINVOKECOMMANDINFO * LPCMINVOKECOMMANDINFO
struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1454
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SW_NORMAL
Definition: winuser.h:772
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()

STDMETHODIMP CStartMenuBtnCtxMenu::QueryContextMenu ( HMENU  hPopup,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
inlineoverride

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:445
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:2184
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: