ReactOS  0.4.14-dev-376-gaedba84
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 ()
 
- 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
 
HWND m_Owner
 
LPITEMIDLIST m_FolderPidl
 

Additional Inherited Members

- Public Types inherited from IContextMenu
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
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) 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 225 of file startctxmnu.cpp.

226  {
227  }

◆ ~CStartMenuBtnCtxMenu()

virtual CStartMenuBtnCtxMenu::~CStartMenuBtnCtxMenu ( )
inlinevirtual

Definition at line 229 of file startctxmnu.cpp.

230  {
231  if (m_FolderPidl)
233  }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:37

Member Function Documentation

◆ AddStartContextMenuItems()

VOID CStartMenuBtnCtxMenu::AddStartContextMenuItems ( IN HMENU  hPopup)
inlineprivate

Definition at line 67 of file startctxmnu.cpp.

68  {
69  WCHAR szBuf[MAX_PATH];
70  HRESULT hRet;
71 
72  /* Add the "Open All Users" menu item */
75  szBuf,
76  _countof(szBuf)))
77  {
78  AppendMenu(hPopup,
79  MF_STRING,
81  szBuf);
82  }
83 
85  {
86  /* Check if we should add menu items for the common start menu */
87  hRet = SHGetFolderPath(m_Owner,
89  NULL,
91  szBuf);
92  if (SUCCEEDED(hRet) && hRet != S_FALSE)
93  {
94  /* The directory exists, but only show the items if the
95  user can actually make any changes to the common start
96  menu. This is most likely only the case if the user
97  has administrative rights! */
98  if (IsUserAnAdmin())
99  {
100  AppendMenu(hPopup,
101  MF_SEPARATOR,
102  0,
103  NULL);
104 
105  /* Add the "Open All Users" menu item */
108  szBuf,
109  _countof(szBuf)))
110  {
111  AppendMenu(hPopup,
112  MF_STRING,
114  szBuf);
115  }
116 
117  /* Add the "Explore All Users" menu item */
120  szBuf,
121  _countof(szBuf)))
122  {
123  AppendMenu(hPopup,
124  MF_STRING,
126  szBuf);
127  }
128  }
129  }
130  }
131  }
#define ID_SHELL_CMD_PROPERTIES
Definition: resource.h:185
#define _countof(array)
Definition: fontsub.cpp:30
#define SHGetFolderPath
Definition: shlobj.h:2001
#define MF_STRING
Definition: winuser.h:138
#define IDS_PROPERTIES
Definition: resource.h:101
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI IsUserAnAdmin(VOID)
Definition: shellord.c:2147
#define MF_SEPARATOR
Definition: winuser.h:137
#define ID_SHELL_CMD_EXPLORE_ALL_USERS
Definition: resource.h:187
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2024
#define AppendMenu
Definition: winuser.h:5632
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
#define MAX_PATH
Definition: compat.h:26
#define IDS_OPEN_ALL_USERS
Definition: resource.h:99
#define ID_SHELL_CMD_OPEN_ALL_USERS
Definition: resource.h:186
#define IDS_EXPLORE_ALL_USERS
Definition: resource.h:100
DWORD WINAPI SHRestricted(RESTRICTIONS policy)
Definition: shpolicy.c:836
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by QueryContextMenu().

◆ CreateContextMenuFromShellFolderPidl()

HRESULT CStartMenuBtnCtxMenu::CreateContextMenuFromShellFolderPidl ( HMENU  hPopup)
inlineprivate

Definition at line 39 of file startctxmnu.cpp.

40  {
41  HRESULT hRet;
42 
44  if (SUCCEEDED(hRet))
45  {
46  if (hPopup != NULL)
47  {
48  hRet = m_Inner->QueryContextMenu(
49  hPopup,
50  0,
53  CMF_VERBSONLY);
54 
55  if (SUCCEEDED(hRet))
56  {
57  return hRet;
58  }
59 
60  DestroyMenu(hPopup);
61  }
62  }
63 
64  return E_FAIL;
65  }
#define ID_SHELL_CMD_LAST
Definition: resource.h:184
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define E_FAIL
Definition: ddrawi.h:102
#define ID_SHELL_CMD_FIRST
Definition: resource.h:183
smooth NULL
Definition: ftsmooth.c:416
#define IID_NULL_PPV_ARG(Itype, ppType)
LONG HRESULT
Definition: typedefs.h:77
CComPtr< IShellFolder > m_Folder
Definition: startctxmnu.cpp:34
BOOL WINAPI DestroyMenu(_In_ HMENU)
CComPtr< IContextMenu > m_Inner
Definition: startctxmnu.cpp:33
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:37
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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

221  {
222  return E_NOTIMPL;
223  }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Initialize()

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

Definition at line 134 of file startctxmnu.cpp.

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

Referenced by CStartMenuBtnCtxMenu_CreateInstance().

◆ InvokeCommand()

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

Implements IContextMenu.

Definition at line 183 of file startctxmnu.cpp.

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

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 142 of file startctxmnu.cpp.

147  {
148  LPITEMIDLIST pidlStart;
149  CComPtr<IShellFolder> psfDesktop;
150  HRESULT hRet;
151 
152  psfDesktop = NULL;
153  m_Inner = NULL;
154 
156 
157  if (pidlStart != NULL)
158  {
159  m_FolderPidl = ILClone(ILFindLastID(pidlStart));
160  ILRemoveLastID(pidlStart);
161 
162  if (m_FolderPidl != NULL)
163  {
164  hRet = SHGetDesktopFolder(&psfDesktop);
165  if (SUCCEEDED(hRet))
166  {
167  hRet = psfDesktop->BindToObject(pidlStart, NULL, IID_PPV_ARG(IShellFolder, &m_Folder));
168  if (SUCCEEDED(hRet))
169  {
171  AddStartContextMenuItems(hPopup);
172  }
173  }
174  }
175 
176  ILFree(pidlStart);
177  }
178 
179  return S_OK;
180  }
#define TRUE
Definition: types.h:120
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:434
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
HRESULT CreateContextMenuFromShellFolderPidl(HMENU hPopup)
Definition: startctxmnu.cpp:39
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
CComPtr< IShellFolder > m_Folder
Definition: startctxmnu.cpp:34
VOID AddStartContextMenuItems(IN HMENU hPopup)
Definition: startctxmnu.cpp:67
CComPtr< IContextMenu > m_Inner
Definition: startctxmnu.cpp:33
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define CSIDL_STARTMENU
Definition: shlobj.h:2014
LPITEMIDLIST m_FolderPidl
Definition: startctxmnu.cpp:37
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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_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: