ReactOS 0.4.15-dev-5666-gc548b97
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 Member Functions

HRESULT CreateContextMenuFromShellFolderPidl (HMENU hPopup)
 
VOID AddStartContextMenuItems (IN HMENU hPopup)
 

Private Attributes

CComPtr< ITrayWindow > m_TrayWnd
 
CComPtr< IContextMenum_Inner
 
CComPtr< IShellFolderm_Folder
 
UINT m_idCmdCmLast
 
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.

Constructor & Destructor Documentation

◆ CStartMenuBtnCtxMenu()

CStartMenuBtnCtxMenu::CStartMenuBtnCtxMenu ( )
inline

Definition at line 227 of file startctxmnu.cpp.

228 {
230 }
#define ID_SHELL_CMD_LAST
Definition: resource.h:186

◆ ~CStartMenuBtnCtxMenu()

virtual CStartMenuBtnCtxMenu::~CStartMenuBtnCtxMenu ( )
inlinevirtual

Definition at line 232 of file startctxmnu.cpp.

233 {
234 if (m_FolderPidl)
236 }
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:38
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925

Member Function Documentation

◆ AddStartContextMenuItems()

VOID CStartMenuBtnCtxMenu::AddStartContextMenuItems ( IN HMENU  hPopup)
inlineprivate

Definition at line 68 of file startctxmnu.cpp.

69 {
70 WCHAR szBuf[MAX_PATH];
71 HRESULT hRet;
72
73 /* Add the "Open All Users" menu item */
76 szBuf,
77 _countof(szBuf)))
78 {
79 AppendMenu(hPopup,
82 szBuf);
83 }
84
86 {
87 /* Check if we should add menu items for the common start menu */
90 NULL,
92 szBuf);
93 if (SUCCEEDED(hRet) && hRet != S_FALSE)
94 {
95 /* The directory exists, but only show the items if the
96 user can actually make any changes to the common start
97 menu. This is most likely only the case if the user
98 has administrative rights! */
99 if (IsUserAnAdmin())
100 {
101 AppendMenu(hPopup,
103 0,
104 NULL);
105
106 /* Add the "Open All Users" menu item */
109 szBuf,
110 _countof(szBuf)))
111 {
112 AppendMenu(hPopup,
113 MF_STRING,
115 szBuf);
116 }
117
118 /* Add the "Explore All Users" menu item */
121 szBuf,
122 _countof(szBuf)))
123 {
124 AppendMenu(hPopup,
125 MF_STRING,
127 szBuf);
128 }
129 }
130 }
131 }
132 }
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
#define IDS_PROPERTIES
Definition: resource.h:101
#define ID_SHELL_CMD_PROPERTIES
Definition: resource.h:187
#define IDS_EXPLORE_ALL_USERS
Definition: resource.h:100
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
Definition: resource.h:189
#define IDS_OPEN_ALL_USERS
Definition: resource.h:99
#define ID_SHELL_CMD_OPEN_ALL_USERS
Definition: resource.h:188
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define SHGetFolderPath
Definition: shlobj.h:2023
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2046
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2001
BOOL WINAPI IsUserAnAdmin(void)
Definition: shellord.c:2540
@ REST_NOCOMMONGROUPS
Definition: shlobj.h:1584
DWORD WINAPI SHRestricted(RESTRICTIONS policy)
Definition: shpolicy.c:827
#define _countof(array)
Definition: sndvol32.h:68
#define S_FALSE
Definition: winerror.h:2357
#define AppendMenu
Definition: winuser.h:5721
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)
inlineprivate

Definition at line 40 of file startctxmnu.cpp.

41 {
42 HRESULT hRet;
43
45 if (SUCCEEDED(hRet))
46 {
47 if (hPopup != NULL)
48 {
49 hRet = m_Inner->QueryContextMenu(
50 hPopup,
51 0,
54 CMF_VERBSONLY);
55
56 if (SUCCEEDED(hRet))
57 {
58 return hRet;
59 }
60
61 DestroyMenu(hPopup);
62 }
63 }
64
65 return E_FAIL;
66 }
#define ID_SHELL_CMD_FIRST
Definition: resource.h:185
CComPtr< IShellFolder > m_Folder
Definition: startctxmnu.cpp:34
CComPtr< IContextMenu > m_Inner
Definition: startctxmnu.cpp:33
#define E_FAIL
Definition: ddrawi.h:102
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI DestroyMenu(_In_ HMENU)
#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 218 of file startctxmnu.cpp.

223 {
224 return E_NOTIMPL;
225 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Initialize()

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

Definition at line 135 of file startctxmnu.cpp.

136 {
137 m_TrayWnd = pTrayWnd;
138 m_Owner = hWndOwner;
139 return S_OK;
140 }
CComPtr< ITrayWindow > m_TrayWnd
Definition: startctxmnu.cpp:32
#define S_OK
Definition: intsafe.h:52

◆ InvokeCommand()

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

Implements IContextMenu.

Definition at line 185 of file startctxmnu.cpp.

186 {
187 UINT uiCmdId = PtrToUlong(lpici->lpVerb);
188 if (uiCmdId != 0)
189 {
190 if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId < m_idCmdCmLast))
191 {
192 CMINVOKECOMMANDINFO cmici = { 0 };
193 CHAR szDir[MAX_PATH];
194
195 /* Setup and invoke the shell command */
196 cmici.cbSize = sizeof(cmici);
197 cmici.hwnd = m_Owner;
198 cmici.lpVerb = MAKEINTRESOURCEA(uiCmdId - ID_SHELL_CMD_FIRST);
199 cmici.nShow = SW_NORMAL;
200
201 /* FIXME: Support Unicode!!! */
203 {
204 cmici.lpDirectory = szDir;
205 }
206
207 m_Inner->InvokeCommand(&cmici);
208 }
209 else
210 {
211 m_TrayWnd->ExecContextMenuCmd(uiCmdId);
212 }
213 }
214 return S_OK;
215 }
#define PtrToUlong(u)
Definition: config.h:107
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
Definition: pidl.c:1278
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define SW_NORMAL
Definition: winuser.h:763
char CHAR
Definition: xmlstorage.h:175

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 143 of file startctxmnu.cpp.

148 {
149 LPITEMIDLIST pidlStart;
150 CComPtr<IShellFolder> psfDesktop;
151 HRESULT hRet;
152
153 psfDesktop = NULL;
154 m_Inner = NULL;
155
157
158 if (pidlStart != NULL)
159 {
160 m_FolderPidl = ILClone(ILFindLastID(pidlStart));
161 ILRemoveLastID(pidlStart);
162
163 if (m_FolderPidl != NULL)
164 {
165 hRet = SHGetDesktopFolder(&psfDesktop);
166 if (SUCCEEDED(hRet))
167 {
168 hRet = psfDesktop->BindToObject(pidlStart, NULL, IID_PPV_ARG(IShellFolder, &m_Folder));
169 if (SUCCEEDED(hRet))
170 {
174 }
175 }
176 }
177
178 ILFree(pidlStart);
179 }
180
181 return S_OK;
182 }
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
VOID AddStartContextMenuItems(IN HMENU hPopup)
Definition: startctxmnu.cpp:68
HRESULT CreateContextMenuFromShellFolderPidl(HMENU hPopup)
Definition: startctxmnu.cpp:40
#define TRUE
Definition: types.h:120
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:434
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define CSIDL_STARTMENU
Definition: shlobj.h:2036
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define HRESULT_CODE(hr)
Definition: winerror.h:76
#define IID_PPV_ARG(Itype, ppType)

Member Data Documentation

◆ m_Folder

CComPtr<IShellFolder> CStartMenuBtnCtxMenu::m_Folder
private

Definition at line 34 of file startctxmnu.cpp.

Referenced by CreateContextMenuFromShellFolderPidl(), and QueryContextMenu().

◆ m_FolderPidl

LPITEMIDLIST CStartMenuBtnCtxMenu::m_FolderPidl
private

◆ m_idCmdCmLast

UINT CStartMenuBtnCtxMenu::m_idCmdCmLast
private

Definition at line 35 of file startctxmnu.cpp.

Referenced by CStartMenuBtnCtxMenu(), InvokeCommand(), and QueryContextMenu().

◆ 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 32 of file startctxmnu.cpp.

Referenced by Initialize(), and InvokeCommand().


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