ReactOS  0.4.15-dev-3428-g0609db5
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)
 
void InsertRecentItem (HMENU hMenu, UINT nID, INT csidl, BOOL bExpand) const
 
HMENU CreateRecentMenu (BOOL bExpandMyDocuments, BOOL bExpandMyPictures) const
 
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 345 of file CStartMenu.cpp.

346  {
347  }

Member Function Documentation

◆ _SetProgramsFolder()

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

Definition at line 349 of file CStartMenu.cpp.

350  {
351  m_psfPrograms = psf;
352  m_pidlPrograms = pidl;
353  return S_OK;
354  }
CComPtr< IShellFolder > m_psfPrograms
Definition: CStartMenu.cpp:69
#define S_OK
Definition: intsafe.h:52
LPITEMIDLIST m_pidlPrograms
Definition: CStartMenu.cpp:71

◆ CallbackSM()

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

Implements IShellMenuCallback.

Definition at line 356 of file CStartMenu.cpp.

361  {
362  switch (uMsg)
363  {
364  case SMC_INITMENU:
365  return OnInitMenu();
366  case SMC_GETINFO:
367  return OnGetInfo(psmd, reinterpret_cast<SMINFO*>(lParam));
368  case SMC_GETOBJECT:
369  return OnGetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
370  case SMC_EXEC:
371  return OnExec(psmd);
372  case SMC_SFEXEC:
373  m_pTrayPriv->Execute(psmd->psf, psmd->pidlItem);
374  break;
375  case 0x10000000: // _FilterPIDL from CMenuSFToolbar
376  if (psmd->psf->CompareIDs(0, psmd->pidlItem, m_pidlPrograms) == 0)
377  return S_OK;
378  return S_FALSE;
379  }
380 
381  return S_FALSE;
382  }
PUITEMID_CHILD pidlItem
Definition: shobjidl.idl:2629
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:644
IShellFolder * psf
Definition: shobjidl.idl:2630
CComPtr< ITrayPriv > m_pTrayPriv
Definition: CStartMenu.cpp:68
HRESULT OnExec(LPSMDATA psmd)
Definition: CStartMenu.cpp:294
HRESULT OnInitMenu()
Definition: CStartMenu.cpp:73
#define S_OK
Definition: intsafe.h:52
HRESULT OnGetObject(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:284
LPITEMIDLIST m_pidlPrograms
Definition: CStartMenu.cpp:71
LPARAM lParam
Definition: combotst.c:139
HRESULT OnGetInfo(LPSMDATA psmd, SMINFO *psminfo)
Definition: CStartMenu.cpp:100

◆ CreateRecentMenu()

HMENU CShellMenuCallback::CreateRecentMenu ( BOOL  bExpandMyDocuments,
BOOL  bExpandMyPictures 
) const
inlineprivate

Definition at line 179 of file CStartMenu.cpp.

180  {
181  HMENU hMenu = ::CreateMenu();
182  InsertRecentItem(hMenu, IDM_MYDOCUMENTS, CSIDL_MYDOCUMENTS, bExpandMyDocuments);
183  InsertRecentItem(hMenu, IDM_MYPICTURES, CSIDL_MYPICTURES, bExpandMyPictures);
184  AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
185  return hMenu;
186  }
HMENU WINAPI CreateMenu(void)
Definition: menu.c:837
#define IDM_MYDOCUMENTS
Definition: shresdef.h:844
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
#define MF_SEPARATOR
Definition: winuser.h:137
void InsertRecentItem(HMENU hMenu, UINT nID, INT csidl, BOOL bExpand) const
Definition: CStartMenu.cpp:153
#define IDM_MYPICTURES
Definition: shresdef.h:845
#define NULL
Definition: types.h:112
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by OnGetSubMenu().

◆ Initialize()

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

Definition at line 335 of file CStartMenu.cpp.

339  {
340  m_pShellMenu = pShellMenu;
341  m_pBandSite = pBandSite;
342  m_pDeskBar = pDeskBar;
343  }
CComPtr< IBandSite > m_pBandSite
Definition: CStartMenu.cpp:66
CComPtr< IShellMenu > m_pShellMenu
Definition: CStartMenu.cpp:65
CComPtr< IDeskBar > m_pDeskBar
Definition: CStartMenu.cpp:67

◆ InsertRecentItem()

void CShellMenuCallback::InsertRecentItem ( HMENU  hMenu,
UINT  nID,
INT  csidl,
BOOL  bExpand 
) const
inlineprivate

Definition at line 153 of file CStartMenu.cpp.

154  {
156  if (!SHGetSpecialFolderPathW(NULL, szPath, csidl, FALSE))
157  {
158  ERR("SHGetSpecialFolderPathW failed\n");
159  return;
160  }
161 
162  LPWSTR pszText = PathFindFileNameW(szPath);
163  if (bExpand)
164  {
165  MENUITEMINFOW mii = { sizeof(mii), MIIM_TYPE | MIIM_ID | MIIM_SUBMENU };
166  mii.fType = MFT_STRING;
167  mii.wID = nID;
168  mii.hSubMenu = ::CreatePopupMenu();
169  mii.dwTypeData = pszText;
170  mii.cch = lstrlenW(pszText);
171  InsertMenuItemW(hMenu, GetMenuItemCount(hMenu), TRUE, &mii);
172  }
173  else
174  {
175  AppendMenuW(hMenu, MF_STRING | MF_ENABLED, nID, pszText);
176  }
177  }
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define MF_STRING
Definition: winuser.h:138
LPWSTR dwTypeData
Definition: winuser.h:3249
#define lstrlenW
Definition: compat.h:609
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define MIIM_SUBMENU
Definition: winuser.h:718
#define FALSE
Definition: types.h:117
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
#define MIIM_ID
Definition: winuser.h:717
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MF_ENABLED
Definition: winuser.h:128
#define MAX_PATH
Definition: compat.h:34
#define MIIM_TYPE
Definition: winuser.h:720
#define ERR(fmt,...)
Definition: debug.h:110
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2948
LPCWSTR szPath
Definition: env.c:37
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define NULL
Definition: types.h:112
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CreateRecentMenu().

◆ OnExec()

HRESULT CShellMenuCallback::OnExec ( LPSMDATA  psmd)
inlineprivate

Definition at line 294 of file CStartMenu.cpp.

295  {
297 
298  // HACK: Because our ShellExecute can't handle CLSID components in paths, we can't launch the paths using the "open" verb.
299  // FIXME: Change this back to using the path as the filename and the "open" verb, once ShellExecute can handle CLSID path components.
300 
301  if (psmd->uId == IDM_CONTROLPANEL)
302  ShellExecuteW(NULL, NULL, L"explorer.exe", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}", NULL, SW_SHOWNORMAL);
303  else if (psmd->uId == IDM_NETWORKCONNECTIONS)
304  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);
305  else if (psmd->uId == IDM_PRINTERSANDFAXES)
306  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);
307  else if (psmd->uId == IDM_MYDOCUMENTS)
308  {
311  else
312  ERR("SHGetSpecialFolderPathW failed\n");
313  }
314  else if (psmd->uId == IDM_MYPICTURES)
315  {
318  else
319  ERR("SHGetSpecialFolderPathW failed\n");
320  }
321  else
323 
324  return S_OK;
325  }
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
#define IDM_MYDOCUMENTS
Definition: shresdef.h:844
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDM_MYPICTURES
Definition: shresdef.h:845
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
#define WM_COMMAND
Definition: winuser.h:1727
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
#define SW_SHOWNORMAL
Definition: winuser.h:764
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2948
LPCWSTR szPath
Definition: env.c:37
#define NULL
Definition: types.h:112
#define CSIDL_PERSONAL
Definition: shlobj.h:2017
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:2274

Referenced by CallbackSM().

◆ OnGetContextMenu()

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

Definition at line 271 of file CStartMenu.cpp.

272  {
273  if (psmd->uId == IDM_PROGRAMS ||
274  psmd->uId == IDM_CONTROLPANEL ||
275  psmd->uId == IDM_NETWORKCONNECTIONS ||
276  psmd->uId == IDM_PRINTERSANDFAXES)
277  {
278  //UNIMPLEMENTED
279  }
280 
281  return S_FALSE;
282  }
#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 100 of file CStartMenu.cpp.

101  {
102  int iconIndex = 0;
103 
104  switch (psmd->uId)
105  {
106  // Smaller "24x24" icons used for the start menu
107  // The bitmaps are still 32x32, but the image is centered
108  case IDM_FAVORITES: iconIndex = -IDI_SHELL_FAVOTITES; break;
109  case IDM_SEARCH: iconIndex = -IDI_SHELL_SEARCH1; break;
110  case IDM_HELPANDSUPPORT: iconIndex = -IDI_SHELL_HELP2; break;
111  case IDM_LOGOFF: iconIndex = -IDI_SHELL_LOGOFF1; break;
112  case IDM_PROGRAMS: iconIndex = -IDI_SHELL_PROGRAMS_FOLDER1; break;
113  case IDM_DOCUMENTS: iconIndex = -IDI_SHELL_RECENT_DOCUMENTS1; break;
114  case IDM_RUN: iconIndex = -IDI_SHELL_RUN1; break;
115  case IDM_SHUTDOWN: iconIndex = -IDI_SHELL_SHUTDOWN1; break;
116  case IDM_SETTINGS: iconIndex = -IDI_SHELL_CONTROL_PANEL1; break;
117  case IDM_MYDOCUMENTS: iconIndex = -IDI_SHELL_MY_DOCUMENTS; break;
118  case IDM_MYPICTURES: iconIndex = -IDI_SHELL_MY_PICTURES; break;
119 
120  case IDM_CONTROLPANEL: iconIndex = -IDI_SHELL_CONTROL_PANEL; break;
121  case IDM_NETWORKCONNECTIONS: iconIndex = -IDI_SHELL_NETWORK_CONNECTIONS2; break;
122  case IDM_PRINTERSANDFAXES: iconIndex = -IDI_SHELL_PRINTER2; break;
123  case IDM_TASKBARANDSTARTMENU: iconIndex = -IDI_SHELL_TSKBAR_STARTMENU; break;
124  //case IDM_SECURITY: iconIndex = -21; break;
125  //case IDM_SYNCHRONIZE: iconIndex = -21; break;
126  //case IDM_DISCONNECT: iconIndex = -21; break;
127  //case IDM_UNDOCKCOMPUTER: iconIndex = -21; break;
128  default:
129  return S_FALSE;
130  }
131 
132  if (iconIndex)
133  {
134  if ((psminfo->dwMask & SMIM_TYPE) != 0)
135  psminfo->dwType = SMIT_STRING;
136  if ((psminfo->dwMask & SMIM_ICON) != 0)
137  psminfo->iIcon = Shell_GetCachedImageIndex(L"shell32.dll", iconIndex, FALSE);
138  if ((psminfo->dwMask & SMIM_FLAGS) != 0)
139  psminfo->dwFlags |= SMIF_ICON;
140 #ifdef TEST_TRACKPOPUPMENU_SUBMENUS
141  if ((psminfo->dwMask & SMIM_FLAGS) != 0)
142  psminfo->dwFlags |= SMIF_TRACKPOPUP;
143 #endif
144  }
145  else
146  {
147  if ((psminfo->dwMask & SMIM_TYPE) != 0)
148  psminfo->dwType = SMIT_SEPARATOR;
149  }
150  return S_OK;
151  }
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
#define IDM_SHUTDOWN
Definition: CStartMenu.cpp:41
#define IDM_MYDOCUMENTS
Definition: shresdef.h:844
#define IDM_SEARCH
Definition: CStartMenu.cpp:45
#define IDI_SHELL_HELP2
Definition: shresdef.h:732
#define IDI_SHELL_CONTROL_PANEL
Definition: shresdef.h:543
#define IDM_TASKBARANDSTARTMENU
Definition: CStartMenu.cpp:35
#define IDI_SHELL_PRINTER2
Definition: shresdef.h:576
#define IDI_SHELL_RECENT_DOCUMENTS1
Definition: shresdef.h:735
#define IDI_SHELL_CONTROL_PANEL1
Definition: shresdef.h:738
#define IDM_RUN
Definition: CStartMenu.cpp:32
#define IDM_SETTINGS
Definition: CStartMenu.cpp:43
#define FALSE
Definition: types.h:117
#define S_FALSE
Definition: winerror.h:2357
#define IDI_SHELL_TSKBAR_STARTMENU
Definition: shresdef.h:561
#define IDI_SHELL_PROGRAMS_FOLDER1
Definition: shresdef.h:734
#define IDI_SHELL_SHUTDOWN1
Definition: shresdef.h:737
#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_MYPICTURES
Definition: shresdef.h:845
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
#define IDM_FAVORITES
Definition: CStartMenu.cpp:42
#define IDI_SHELL_SEARCH1
Definition: shresdef.h:731
static const WCHAR L[]
Definition: oid.c:1250
#define IDI_SHELL_NETWORK_CONNECTIONS2
Definition: shresdef.h:669
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44
#define S_OK
Definition: intsafe.h:52
#define IDI_SHELL_MY_DOCUMENTS
Definition: shresdef.h:647
#define IDM_LOGOFF
Definition: CStartMenu.cpp:33
#define IDI_SHELL_MY_PICTURES
Definition: shresdef.h:648
#define IDM_HELPANDSUPPORT
Definition: CStartMenu.cpp:38
#define IDI_SHELL_FAVOTITES
Definition: shresdef.h:730
#define IDI_SHELL_RUN1
Definition: shresdef.h:736
#define IDI_SHELL_LOGOFF1
Definition: shresdef.h:733

Referenced by CallbackSM().

◆ OnGetObject()

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

Definition at line 284 of file CStartMenu.cpp.

285  {
286  if (IsEqualIID(iid, IID_IShellMenu))
287  return OnGetSubMenu(psmd, iid, pv);
288  else if (IsEqualIID(iid, IID_IContextMenu))
289  return OnGetContextMenu(psmd, iid, pv);
290 
291  return S_FALSE;
292  }
HRESULT OnGetContextMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:271
#define S_FALSE
Definition: winerror.h:2357
HRESULT OnGetSubMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:188
#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 188 of file CStartMenu.cpp.

189  {
190  HRESULT hr;
191  int csidl = 0;
192  IShellMenu *pShellMenu;
193 
195  if (FAILED_UNEXPECTEDLY(hr))
196  return hr;
197 
198  hr = pShellMenu->Initialize(this, 0, ANCESTORDEFAULT, SMINIT_VERTICAL);
199  if (FAILED_UNEXPECTEDLY(hr))
200  return hr;
201 
202  switch (psmd->uId)
203  {
204  case IDM_PROGRAMS: csidl = CSIDL_PROGRAMS; break;
205  case IDM_FAVORITES: csidl = CSIDL_FAVORITES; break;
206  case IDM_DOCUMENTS: csidl = CSIDL_RECENT; break;
207  case IDM_MYDOCUMENTS: csidl = CSIDL_MYDOCUMENTS; break;
208  case IDM_MYPICTURES: csidl = CSIDL_MYPICTURES; break;
209  }
210 
211  if (csidl)
212  {
213  IShellFolder *psfStartMenu;
214  DWORD dwFlags = SMSET_TOP;
215 
216  if (csidl == CSIDL_PROGRAMS && m_psfPrograms)
217  {
218  psfStartMenu = m_psfPrograms;
219  }
220  else
221  {
222  if (csidl == CSIDL_RECENT)
223  {
224  BOOL bExpandMyDocuments = FALSE; /* FIXME: Get value from registry */
225  BOOL bExpandMyPictures = FALSE; /* FIXME: Get value from registry */
226  HMENU hMenu = CreateRecentMenu(bExpandMyDocuments, bExpandMyPictures);
227  if (hMenu == NULL)
228  ERR("CreateRecentMenu failed\n");
229 
230  hr = pShellMenu->SetMenu(hMenu, NULL, SMSET_BOTTOM);
231  if (FAILED_UNEXPECTEDLY(hr))
232  return hr;
233 
234  dwFlags = SMSET_BOTTOM;
235  }
236 
237  LPITEMIDLIST pidlStartMenu;
238  IShellFolder *psfDestop;
239  hr = SHGetFolderLocation(NULL, csidl, 0, 0, &pidlStartMenu);
240  if (FAILED_UNEXPECTEDLY(hr))
241  return hr;
242 
243  hr = SHGetDesktopFolder(&psfDestop);
244  if (FAILED_UNEXPECTEDLY(hr))
245  return hr;
246 
247  hr = psfDestop->BindToObject(pidlStartMenu, NULL, IID_PPV_ARG(IShellFolder, &psfStartMenu));
248  if (FAILED_UNEXPECTEDLY(hr))
249  return hr;
250  }
251 
252  hr = pShellMenu->SetShellFolder(psfStartMenu, NULL, NULL, dwFlags);
253  if (FAILED_UNEXPECTEDLY(hr))
254  return hr;
255  }
256  else
257  {
258  MENUITEMINFO mii;
259  mii.cbSize = sizeof(mii);
260  mii.fMask = MIIM_SUBMENU;
261  if (GetMenuItemInfoW(psmd->hmenu, psmd->uId, FALSE, &mii))
262  {
263  hr = pShellMenu->SetMenu(mii.hSubMenu, NULL, SMSET_BOTTOM);
264  if (FAILED_UNEXPECTEDLY(hr))
265  return hr;
266  }
267  }
268  return pShellMenu->QueryInterface(iid, pv);
269  }
#define IDM_MYDOCUMENTS
Definition: shresdef.h:844
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
#define IID_PPV_ARG(Itype, ppType)
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
#define CSIDL_RECENT
Definition: shlobj.h:2020
#define MIIM_SUBMENU
Definition: winuser.h:718
#define FALSE
Definition: types.h:117
#define CSIDL_FAVORITES
Definition: shlobj.h:2018
unsigned int BOOL
Definition: ntddk_ex.h:94
CComPtr< IShellFolder > m_psfPrograms
Definition: CStartMenu.cpp:69
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
#define IDM_MYPICTURES
Definition: shresdef.h:845
LONG HRESULT
Definition: typedefs.h:79
#define IDM_FAVORITES
Definition: CStartMenu.cpp:42
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT Initialize([in] IShellMenuCallback *psmc, [in] UINT uId, [in] UINT uIdAncestor, [in] DWORD dwFlags)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:110
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
HRESULT SetShellFolder([in] IShellFolder *psf, [in] PCIDLIST_ABSOLUTE pidlFolder, [in] HKEY hKey, [in] DWORD dwFlags)
#define NULL
Definition: types.h:112
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:2980
#define CSIDL_PROGRAMS
Definition: shlobj.h:2014
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HMENU hmenu
Definition: shobjidl.idl:2622
HMENU CreateRecentMenu(BOOL bExpandMyDocuments, BOOL bExpandMyPictures) const
Definition: CStartMenu.cpp:179

Referenced by OnGetObject().

◆ OnInitMenu()

HRESULT CShellMenuCallback::OnInitMenu ( )
inlineprivate

Definition at line 73 of file CStartMenu.cpp.

74  {
75  HMENU hmenu;
76  HRESULT hr;
77 
78  if (m_pTrayPriv.p)
79  return S_OK;
80 
83  return hr;
84 
87  return hr;
88 
89  hr = m_pTrayPriv->AppendMenuW(&hmenu);
91  return hr;
92 
93  hr = m_pShellMenu->SetMenu(hmenu, NULL, SMSET_BOTTOM);
95  return hr;
96 
97  return hr;
98  }
HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite)
Definition: ordinal.c:2593
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:1329
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
CComPtr< ITrayPriv > m_pTrayPriv
Definition: CStartMenu.cpp:68
CComPtr< IShellMenu > m_pShellMenu
Definition: CStartMenu.cpp:65
CComPtr< IDeskBar > m_pDeskBar
Definition: CStartMenu.cpp:67
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
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 64 of file CStartMenu.cpp.

Referenced by OnExec(), and OnInitMenu().

◆ m_pBandSite

CComPtr<IBandSite> CShellMenuCallback::m_pBandSite
private

Definition at line 66 of file CStartMenu.cpp.

Referenced by Initialize().

◆ m_pDeskBar

CComPtr<IDeskBar> CShellMenuCallback::m_pDeskBar
private

Definition at line 67 of file CStartMenu.cpp.

Referenced by Initialize(), and OnInitMenu().

◆ m_pidlPrograms

LPITEMIDLIST CShellMenuCallback::m_pidlPrograms
private

Definition at line 71 of file CStartMenu.cpp.

Referenced by _SetProgramsFolder(), and CallbackSM().

◆ m_psfPrograms

CComPtr<IShellFolder> CShellMenuCallback::m_psfPrograms
private

Definition at line 69 of file CStartMenu.cpp.

Referenced by _SetProgramsFolder(), and OnGetSubMenu().

◆ m_pShellMenu

CComPtr<IShellMenu> CShellMenuCallback::m_pShellMenu
private

Definition at line 65 of file CStartMenu.cpp.

Referenced by Initialize(), and OnInitMenu().

◆ m_pTrayPriv

CComPtr<ITrayPriv> CShellMenuCallback::m_pTrayPriv
private

Definition at line 68 of file CStartMenu.cpp.

Referenced by CallbackSM(), and OnInitMenu().


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