ReactOS  0.4.14-dev-342-gdc047f9
CShellMenuCallback Class Reference
Inheritance diagram for CShellMenuCallback:
Collaboration diagram for CShellMenuCallback:

Public Member Functions

void Initialize (IShellMenu *pShellMenu, IBandSite *pBandSite, IDeskBar *pDeskBar)
 
 ~CShellMenuCallback ()
 
HRESULT _SetProgramsFolder (IShellFolder *psf, LPITEMIDLIST pidl)
 
HRESULT STDMETHODCALLTYPE CallbackSM (LPSMDATA psmd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- 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 OnInitMenu ()
 
HRESULT OnGetInfo (LPSMDATA psmd, SMINFO *psminfo)
 
HRESULT OnGetSubMenu (LPSMDATA psmd, REFIID iid, void **pv)
 
HRESULT OnGetContextMenu (LPSMDATA psmd, REFIID iid, void **pv)
 
HRESULT OnGetObject (LPSMDATA psmd, REFIID iid, void **pv)
 
HRESULT OnExec (LPSMDATA psmd)
 

Private Attributes

HWND m_hwndTray
 
CComPtr< IShellMenum_pShellMenu
 
CComPtr< IBandSitem_pBandSite
 
CComPtr< IDeskBarm_pDeskBar
 
CComPtr< ITrayPriv > m_pTrayPriv
 
CComPtr< IShellFolderm_psfPrograms
 
LPITEMIDLIST m_pidlPrograms
 

Additional Inherited Members

- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- 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
 

Detailed Description

Definition at line 59 of file CStartMenu.cpp.

Constructor & Destructor Documentation

◆ ~CShellMenuCallback()

CShellMenuCallback::~CShellMenuCallback ( )
inline

Definition at line 276 of file CStartMenu.cpp.

277  {
278  }

Member Function Documentation

◆ _SetProgramsFolder()

HRESULT CShellMenuCallback::_SetProgramsFolder ( IShellFolder psf,
LPITEMIDLIST  pidl 
)
inline

Definition at line 280 of file CStartMenu.cpp.

281  {
282  m_psfPrograms = psf;
283  m_pidlPrograms = pidl;
284  return S_OK;
285  }
CComPtr< IShellFolder > m_psfPrograms
Definition: CStartMenu.cpp:70
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST m_pidlPrograms
Definition: CStartMenu.cpp:72

◆ CallbackSM()

HRESULT STDMETHODCALLTYPE CShellMenuCallback::CallbackSM ( LPSMDATA  psmd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
inline

Implements IShellMenuCallback.

Definition at line 287 of file CStartMenu.cpp.

292  {
293  switch (uMsg)
294  {
295  case SMC_INITMENU:
296  return OnInitMenu();
297  case SMC_GETINFO:
298  return OnGetInfo(psmd, reinterpret_cast<SMINFO*>(lParam));
299  case SMC_GETOBJECT:
300  return OnGetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
301  case SMC_EXEC:
302  return OnExec(psmd);
303  case SMC_SFEXEC:
304  m_pTrayPriv->Execute(psmd->psf, psmd->pidlItem);
305  break;
306  case 0x10000000: // _FilterPIDL from CMenuSFToolbar
307  if (psmd->psf->CompareIDs(0, psmd->pidlItem, m_pidlPrograms) == 0)
308  return S_OK;
309  return S_FALSE;
310  }
311 
312  return S_FALSE;
313  }
LPITEMIDLIST pidlItem
Definition: shobjidl.idl:2624
WPARAM wParam
Definition: combotst.c:138
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
#define S_FALSE
Definition: winerror.h:2357
#define SMC_EXEC
Definition: undocshell.h:611
IShellFolder * psf
Definition: shobjidl.idl:2625
CComPtr< ITrayPriv > m_pTrayPriv
Definition: CStartMenu.cpp:69
HRESULT OnExec(LPSMDATA psmd)
Definition: CStartMenu.cpp:241
HRESULT OnInitMenu()
Definition: CStartMenu.cpp:74
#define S_OK
Definition: intsafe.h:59
HRESULT OnGetObject(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:231
LPITEMIDLIST m_pidlPrograms
Definition: CStartMenu.cpp:72
LPARAM lParam
Definition: combotst.c:139
HRESULT OnGetInfo(LPSMDATA psmd, SMINFO *psminfo)
Definition: CStartMenu.cpp:101

◆ Initialize()

void CShellMenuCallback::Initialize ( IShellMenu pShellMenu,
IBandSite pBandSite,
IDeskBar pDeskBar 
)
inline

Definition at line 266 of file CStartMenu.cpp.

270  {
271  m_pShellMenu = pShellMenu;
272  m_pBandSite = pBandSite;
273  m_pDeskBar = pDeskBar;
274  }
CComPtr< IBandSite > m_pBandSite
Definition: CStartMenu.cpp:67
CComPtr< IShellMenu > m_pShellMenu
Definition: CStartMenu.cpp:66
CComPtr< IDeskBar > m_pDeskBar
Definition: CStartMenu.cpp:68

◆ OnExec()

HRESULT CShellMenuCallback::OnExec ( LPSMDATA  psmd)
inlineprivate

Definition at line 241 of file CStartMenu.cpp.

242  {
243  // HACK: Because our ShellExecute can't handle CLSID components in paths, we can't launch the paths using the "open" verb.
244  // FIXME: Change this back to using the path as the filename and the "open" verb, once ShellExecute can handle CLSID path components.
245 
246  if (psmd->uId == IDM_CONTROLPANEL)
247  ShellExecuteW(NULL, NULL, L"explorer.exe", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}", NULL, SW_SHOWNORMAL);
248  else if (psmd->uId == IDM_NETWORKCONNECTIONS)
249  ShellExecuteW(NULL, NULL, L"explorer.exe", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}", NULL, SW_SHOWNORMAL);
250  else if (psmd->uId == IDM_PRINTERSANDFAXES)
251  ShellExecuteW(NULL, NULL, L"explorer.exe", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}", NULL, SW_SHOWNORMAL);
252  else
254 
255  return S_OK;
256  }
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
smooth NULL
Definition: ftsmooth.c:416
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
static const WCHAR L[]
Definition: oid.c:1250
#define WM_COMMAND
Definition: winuser.h:1722
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44
#define S_OK
Definition: intsafe.h:59
#define SW_SHOWNORMAL
Definition: winuser.h:764
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2246

Referenced by CallbackSM().

◆ OnGetContextMenu()

HRESULT CShellMenuCallback::OnGetContextMenu ( LPSMDATA  psmd,
REFIID  iid,
void **  pv 
)
inlineprivate

Definition at line 218 of file CStartMenu.cpp.

219  {
220  if (psmd->uId == IDM_PROGRAMS ||
221  psmd->uId == IDM_CONTROLPANEL ||
222  psmd->uId == IDM_NETWORKCONNECTIONS ||
223  psmd->uId == IDM_PRINTERSANDFAXES)
224  {
225  //UNIMPLEMENTED
226  }
227 
228  return S_FALSE;
229  }
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
#define S_FALSE
Definition: winerror.h:2357
#define IDM_PROGRAMS
Definition: CStartMenu.cpp:39
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44

Referenced by OnGetObject().

◆ OnGetInfo()

HRESULT CShellMenuCallback::OnGetInfo ( LPSMDATA  psmd,
SMINFO psminfo 
)
inlineprivate

Definition at line 101 of file CStartMenu.cpp.

102  {
103  int iconIndex = 0;
104 
105  switch (psmd->uId)
106  {
107  // Smaller "24x24" icons used for the start menu
108  // The bitmaps are still 32x32, but the image is centered
109  case IDM_FAVORITES: iconIndex = -322; break;
110  case IDM_SEARCH: iconIndex = -323; break;
111  case IDM_HELPANDSUPPORT: iconIndex = -324; break;
112  case IDM_LOGOFF: iconIndex = -325; break;
113  case IDM_PROGRAMS: iconIndex = -326; break;
114  case IDM_DOCUMENTS: iconIndex = -327; break;
115  case IDM_RUN: iconIndex = -328; break;
116  case IDM_SHUTDOWN: iconIndex = -329; break;
117  case IDM_SETTINGS: iconIndex = -330; break;
118 
119  case IDM_CONTROLPANEL: iconIndex = -22; break;
120  case IDM_NETWORKCONNECTIONS: iconIndex = -257; break;
121  case IDM_PRINTERSANDFAXES: iconIndex = -138; break;
122  case IDM_TASKBARANDSTARTMENU: iconIndex = -40; break;
123  //case IDM_SECURITY: iconIndex = -21; break;
124  //case IDM_SYNCHRONIZE: iconIndex = -21; break;
125  //case IDM_DISCONNECT: iconIndex = -21; break;
126  //case IDM_UNDOCKCOMPUTER: iconIndex = -21; break;
127  default:
128  return S_FALSE;
129  }
130 
131  if (iconIndex)
132  {
133  if ((psminfo->dwMask & SMIM_TYPE) != 0)
134  psminfo->dwType = SMIT_STRING;
135  if ((psminfo->dwMask & SMIM_ICON) != 0)
136  psminfo->iIcon = Shell_GetCachedImageIndex(L"shell32.dll", iconIndex, FALSE);
137  if ((psminfo->dwMask & SMIM_FLAGS) != 0)
138  psminfo->dwFlags |= SMIF_ICON;
139 #ifdef TEST_TRACKPOPUPMENU_SUBMENUS
140  if ((psminfo->dwMask & SMIM_FLAGS) != 0)
141  psminfo->dwFlags |= SMIF_TRACKPOPUP;
142 #endif
143  }
144  else
145  {
146  if ((psminfo->dwMask & SMIM_TYPE) != 0)
147  psminfo->dwType = SMIT_SEPARATOR;
148  }
149  return S_OK;
150  }
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
#define IDM_SHUTDOWN
Definition: CStartMenu.cpp:41
#define IDM_SEARCH
Definition: CStartMenu.cpp:45
#define IDM_TASKBARANDSTARTMENU
Definition: CStartMenu.cpp:35
#define IDM_RUN
Definition: CStartMenu.cpp:32
#define IDM_SETTINGS
Definition: CStartMenu.cpp:43
#define S_FALSE
Definition: winerror.h:2357
#define IDM_DOCUMENTS
Definition: CStartMenu.cpp:37
#define IDM_PROGRAMS
Definition: CStartMenu.cpp:39
EXTERN_C INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:861
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
#define IDM_FAVORITES
Definition: CStartMenu.cpp:42
static const WCHAR L[]
Definition: oid.c:1250
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44
#define S_OK
Definition: intsafe.h:59
#define IDM_LOGOFF
Definition: CStartMenu.cpp:33
#define IDM_HELPANDSUPPORT
Definition: CStartMenu.cpp:38

Referenced by CallbackSM().

◆ OnGetObject()

HRESULT CShellMenuCallback::OnGetObject ( LPSMDATA  psmd,
REFIID  iid,
void **  pv 
)
inlineprivate

Definition at line 231 of file CStartMenu.cpp.

232  {
233  if (IsEqualIID(iid, IID_IShellMenu))
234  return OnGetSubMenu(psmd, iid, pv);
235  else if (IsEqualIID(iid, IID_IContextMenu))
236  return OnGetContextMenu(psmd, iid, pv);
237 
238  return S_FALSE;
239  }
HRESULT OnGetContextMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:218
#define S_FALSE
Definition: winerror.h:2357
HRESULT OnGetSubMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:152
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by CallbackSM().

◆ OnGetSubMenu()

HRESULT CShellMenuCallback::OnGetSubMenu ( LPSMDATA  psmd,
REFIID  iid,
void **  pv 
)
inlineprivate

Definition at line 152 of file CStartMenu.cpp.

153  {
154  HRESULT hr;
155  int csidl = 0;
156  IShellMenu *pShellMenu;
157 
159  if (FAILED_UNEXPECTEDLY(hr))
160  return hr;
161 
162  hr = pShellMenu->Initialize(this, 0, ANCESTORDEFAULT, SMINIT_VERTICAL);
163  if (FAILED_UNEXPECTEDLY(hr))
164  return hr;
165 
166  switch (psmd->uId)
167  {
168  case IDM_PROGRAMS: csidl = CSIDL_PROGRAMS; break;
169  case IDM_FAVORITES: csidl = CSIDL_FAVORITES; break;
170  case IDM_DOCUMENTS: csidl = CSIDL_RECENT; break;
171  }
172 
173  if (csidl)
174  {
175  IShellFolder *psfStartMenu;
176 
177  if (csidl == CSIDL_PROGRAMS && m_psfPrograms)
178  {
179  psfStartMenu = m_psfPrograms;
180  }
181  else
182  {
183  LPITEMIDLIST pidlStartMenu;
184  IShellFolder *psfDestop;
185  hr = SHGetFolderLocation(NULL, csidl, 0, 0, &pidlStartMenu);
186  if (FAILED_UNEXPECTEDLY(hr))
187  return hr;
188 
189  hr = SHGetDesktopFolder(&psfDestop);
190  if (FAILED_UNEXPECTEDLY(hr))
191  return hr;
192 
193  hr = psfDestop->BindToObject(pidlStartMenu, NULL, IID_PPV_ARG(IShellFolder, &psfStartMenu));
194  if (FAILED_UNEXPECTEDLY(hr))
195  return hr;
196  }
197 
198  hr = pShellMenu->SetShellFolder(psfStartMenu, NULL, NULL, 0);
199  if (FAILED_UNEXPECTEDLY(hr))
200  return hr;
201 
202  }
203  else
204  {
205  MENUITEMINFO mii;
206  mii.cbSize = sizeof(mii);
207  mii.fMask = MIIM_SUBMENU;
208  if (GetMenuItemInfoW(psmd->hmenu, psmd->uId, FALSE, &mii))
209  {
210  hr = pShellMenu->SetMenu(mii.hSubMenu, NULL, SMSET_BOTTOM);
211  if (FAILED_UNEXPECTEDLY(hr))
212  return hr;
213  }
214  }
215  return pShellMenu->QueryInterface(iid, pv);
216  }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define CSIDL_RECENT
Definition: shlobj.h:2011
HRESULT SetShellFolder([in] IShellFolder *psf, [in] LPCITEMIDLIST pidlFolder, [in] HKEY hKey, [in] DWORD dwFlags)
#define MIIM_SUBMENU
Definition: winuser.h:718
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
smooth NULL
Definition: ftsmooth.c:416
CComPtr< IShellFolder > m_psfPrograms
Definition: CStartMenu.cpp:70
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define IDM_DOCUMENTS
Definition: CStartMenu.cpp:37
HRESULT SetMenu([in] HMENU hmenu, [in] HWND hwnd, [in] DWORD dwFlags)
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define IDM_PROGRAMS
Definition: CStartMenu.cpp:39
LONG HRESULT
Definition: typedefs.h:77
#define IDM_FAVORITES
Definition: CStartMenu.cpp:42
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
HRESULT Initialize([in] IShellMenuCallback *psmc, [in] UINT uId, [in] UINT uIdAncestor, [in] DWORD dwFlags)
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2672
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
HMENU hmenu
Definition: shobjidl.idl:2617

Referenced by OnGetObject().

◆ OnInitMenu()

HRESULT CShellMenuCallback::OnInitMenu ( )
inlineprivate

Definition at line 74 of file CStartMenu.cpp.

75  {
76  HMENU hmenu;
77  HRESULT hr;
78 
79  if (m_pTrayPriv.p)
80  return S_OK;
81 
84  return hr;
85 
88  return hr;
89 
90  hr = m_pTrayPriv->AppendMenuW(&hmenu);
92  return hr;
93 
94  hr = m_pShellMenu->SetMenu(hmenu, NULL, SMSET_BOTTOM);
96  return hr;
97 
98  return hr;
99  }
HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite)
Definition: ordinal.c:2547
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
#define IID_PPV_ARG(Itype, ppType)
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1283
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< ITrayPriv > m_pTrayPriv
Definition: CStartMenu.cpp:69
CComPtr< IShellMenu > m_pShellMenu
Definition: CStartMenu.cpp:66
CComPtr< IDeskBar > m_pDeskBar
Definition: CStartMenu.cpp:68
#define S_OK
Definition: intsafe.h:59
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by CallbackSM().

Member Data Documentation

◆ m_hwndTray

HWND CShellMenuCallback::m_hwndTray
private

Definition at line 65 of file CStartMenu.cpp.

Referenced by OnExec(), and OnInitMenu().

◆ m_pBandSite

CComPtr<IBandSite> CShellMenuCallback::m_pBandSite
private

Definition at line 67 of file CStartMenu.cpp.

Referenced by Initialize().

◆ m_pDeskBar

CComPtr<IDeskBar> CShellMenuCallback::m_pDeskBar
private

Definition at line 68 of file CStartMenu.cpp.

Referenced by Initialize(), and OnInitMenu().

◆ m_pidlPrograms

LPITEMIDLIST CShellMenuCallback::m_pidlPrograms
private

Definition at line 72 of file CStartMenu.cpp.

Referenced by _SetProgramsFolder(), and CallbackSM().

◆ m_psfPrograms

CComPtr<IShellFolder> CShellMenuCallback::m_psfPrograms
private

Definition at line 70 of file CStartMenu.cpp.

Referenced by _SetProgramsFolder(), and OnGetSubMenu().

◆ m_pShellMenu

CComPtr<IShellMenu> CShellMenuCallback::m_pShellMenu
private

Definition at line 66 of file CStartMenu.cpp.

Referenced by Initialize(), and OnInitMenu().

◆ m_pTrayPriv

CComPtr<ITrayPriv> CShellMenuCallback::m_pTrayPriv
private

Definition at line 69 of file CStartMenu.cpp.

Referenced by CallbackSM(), and OnInitMenu().


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