ReactOS 0.4.16-dev-197-g92996da
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 ()
 
HRESULT CallbackSM ([in, out] LPSMDATA psmd, [in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam)
 
- 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 AddOrSetMenuItem (HMENU hMenu, UINT nID, INT csidl, BOOL bExpand, BOOL bAdd=TRUE, BOOL bSetText=TRUE) const
 
BOOL GetAdvancedValue (LPCWSTR pszName, BOOL bDefault=FALSE) const
 
HMENU CreateRecentMenu () const
 
void UpdateSettingsMenu (HMENU hMenu)
 
HRESULT AddStartMenuItems (IShellMenu *pShellMenu, INT csidl, DWORD dwFlags, IShellFolder *psf=NULL)
 
HRESULT OnGetSubMenu (LPSMDATA psmd, REFIID iid, void **pv)
 
INT CSIDLFromID (UINT uId) const
 
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 450 of file CStartMenu.cpp.

451 {
452 }

Member Function Documentation

◆ _SetProgramsFolder()

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

Definition at line 454 of file CStartMenu.cpp.

455 {
456 m_psfPrograms = psf;
457 m_pidlPrograms = pidl;
458 return S_OK;
459 }
LPITEMIDLIST m_pidlPrograms
Definition: CStartMenu.cpp:71
CComPtr< IShellFolder > m_psfPrograms
Definition: CStartMenu.cpp:69
#define S_OK
Definition: intsafe.h:52

◆ AddOrSetMenuItem()

void CShellMenuCallback::AddOrSetMenuItem ( HMENU  hMenu,
UINT  nID,
INT  csidl,
BOOL  bExpand,
BOOL  bAdd = TRUE,
BOOL  bSetText = TRUE 
) const
inlineprivate

Definition at line 156 of file CStartMenu.cpp.

158 {
159 MENUITEMINFOW mii = { sizeof(mii), MIIM_ID | MIIM_SUBMENU };
160 mii.wID = nID;
161
162 SHFILEINFOW fileInfo = { 0 };
163 if (bAdd || bSetText)
164 {
165 LPITEMIDLIST pidl;
166 if (SHGetSpecialFolderLocation(NULL, csidl, &pidl) != S_OK)
167 {
168 ERR("SHGetSpecialFolderLocation failed\n");
169 return;
170 }
171
172 SHGetFileInfoW((LPWSTR)pidl, 0, &fileInfo, sizeof(fileInfo),
174 CoTaskMemFree(pidl);
175
176 mii.fMask |= MIIM_TYPE;
177 mii.fType = MFT_STRING;
178 mii.dwTypeData = fileInfo.szDisplayName;
179 }
180
181 if (bExpand)
183
184 if (bAdd)
185 InsertMenuItemW(hMenu, GetMenuItemCount(hMenu), TRUE, &mii);
186 else
187 SetMenuItemInfoW(hMenu, nID, FALSE, &mii);
188 }
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3257
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:414
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
#define SHGFI_PIDL
Definition: shellapi.h:180
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:375
LPWSTR dwTypeData
Definition: winuser.h:3272
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define MIIM_ID
Definition: winuser.h:725
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define MIIM_SUBMENU
Definition: winuser.h:726
#define MFT_STRING
Definition: winuser.h:749
#define MIIM_TYPE
Definition: winuser.h:728
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CreateRecentMenu(), and UpdateSettingsMenu().

◆ AddStartMenuItems()

HRESULT CShellMenuCallback::AddStartMenuItems ( IShellMenu pShellMenu,
INT  csidl,
DWORD  dwFlags,
IShellFolder psf = NULL 
)
inlineprivate

Definition at line 240 of file CStartMenu.cpp.

241 {
242 CComHeapPtr<ITEMIDLIST> pidlFolder;
243 CComPtr<IShellFolder> psfDesktop;
244 CComPtr<IShellFolder> pShellFolder;
245 HRESULT hr;
246
247 hr = SHGetFolderLocation(NULL, csidl, 0, 0, &pidlFolder);
249 return hr;
250
251 if (psf)
252 {
253 pShellFolder = psf;
254 }
255 else
256 {
257 hr = SHGetDesktopFolder(&psfDesktop);
259 return hr;
260
261 hr = psfDesktop->BindToObject(pidlFolder, NULL, IID_PPV_ARG(IShellFolder, &pShellFolder));
263 return hr;
264 }
265
266 hr = pShellMenu->SetShellFolder(pShellFolder, pidlFolder, NULL, dwFlags);
268 return hr;
269
270 return hr;
271 }
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3150
HRESULT SetShellFolder([in] IShellFolder *psf, [in] PCIDLIST_ABSOLUTE pidlFolder, [in] HKEY hKey, [in] DWORD dwFlags)
HRESULT hr
Definition: shlfolder.c:183
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define IID_PPV_ARG(Itype, ppType)

Referenced by OnGetSubMenu().

◆ CallbackSM()

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

Implements IShellMenuCallback.

Definition at line 461 of file CStartMenu.cpp.

466 {
467 switch (uMsg)
468 {
469 case SMC_INITMENU:
470 return OnInitMenu();
471 case SMC_GETINFO:
472 return OnGetInfo(psmd, reinterpret_cast<SMINFO*>(lParam));
473 case SMC_GETOBJECT:
474 return OnGetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
475 case SMC_EXEC:
476 return OnExec(psmd);
477 case SMC_SFEXEC:
478 m_pTrayPriv->Execute(psmd->psf, psmd->pidlItem);
479 break;
480 case 0x10000000: // _FilterPIDL from CMenuSFToolbar
481 if (psmd->psf->CompareIDs(0, psmd->pidlItem, m_pidlPrograms) == 0)
482 return S_OK;
483 return S_FALSE;
484 }
485
486 return S_FALSE;
487 }
HRESULT OnGetObject(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:389
CComPtr< ITrayPriv > m_pTrayPriv
Definition: CStartMenu.cpp:68
HRESULT OnGetInfo(LPSMDATA psmd, SMINFO *psminfo)
Definition: CStartMenu.cpp:103
HRESULT OnInitMenu()
Definition: CStartMenu.cpp:73
HRESULT OnExec(LPSMDATA psmd)
Definition: CStartMenu.cpp:399
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
PUITEMID_CHILD pidlItem
Definition: shobjidl.idl:2748
IShellFolder * psf
Definition: shobjidl.idl:2749
#define SMC_EXEC
Definition: undocshell.h:755
#define S_FALSE
Definition: winerror.h:2357

◆ CreateRecentMenu()

HMENU CShellMenuCallback::CreateRecentMenu ( ) const
inlineprivate

Definition at line 197 of file CStartMenu.cpp.

198 {
199 HMENU hMenu = ::CreateMenu();
200 BOOL bAdded = FALSE;
201
202 // My Documents
204 GetAdvancedValue(L"Start_ShowMyDocs", TRUE))
205 {
206 BOOL bExpand = GetAdvancedValue(L"CascadeMyDocuments", FALSE);
208 bAdded = TRUE;
209 }
210
211 // My Pictures
213 GetAdvancedValue(L"Start_ShowMyPics", TRUE))
214 {
215 BOOL bExpand = GetAdvancedValue(L"CascadeMyPictures", FALSE);
217 bAdded = TRUE;
218 }
219
220 if (bAdded)
221 AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
222
223 return hMenu;
224 }
BOOL GetAdvancedValue(LPCWSTR pszName, BOOL bDefault=FALSE) const
Definition: CStartMenu.cpp:190
void AddOrSetMenuItem(HMENU hMenu, UINT nID, INT csidl, BOOL bExpand, BOOL bAdd=TRUE, BOOL bSetText=TRUE) const
Definition: CStartMenu.cpp:156
unsigned int BOOL
Definition: ntddk_ex.h:94
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define L(x)
Definition: ntvdm.h:50
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2185
#define CSIDL_MYPICTURES
Definition: shlobj.h:2211
@ REST_NOSMMYPICS
Definition: shlobj.h:1758
@ REST_NOSMMYDOCS
Definition: shlobj.h:1756
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
#define IDM_MYPICTURES
Definition: shresdef.h:881
#define IDM_MYDOCUMENTS
Definition: shresdef.h:880
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829
#define MF_SEPARATOR
Definition: winuser.h:137
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)

Referenced by OnGetSubMenu().

◆ CSIDLFromID()

INT CShellMenuCallback::CSIDLFromID ( UINT  uId) const
inlineprivate

Definition at line 350 of file CStartMenu.cpp.

351 {
352 switch (uId)
353 {
354 case IDM_PROGRAMS: return CSIDL_PROGRAMS;
355 case IDM_FAVORITES: return CSIDL_FAVORITES;
356 case IDM_DOCUMENTS: return CSIDL_RECENT;
358 case IDM_MYPICTURES: return CSIDL_MYPICTURES;
359 case IDM_CONTROLPANEL: return CSIDL_CONTROLS;
362 default: return 0;
363 }
364 }
#define IDM_FAVORITES
Definition: CStartMenu.cpp:42
#define IDM_NETWORKCONNECTIONS
Definition: CStartMenu.cpp:47
#define IDM_CONTROLPANEL
Definition: CStartMenu.cpp:40
#define IDM_PRINTERSANDFAXES
Definition: CStartMenu.cpp:44
#define IDM_PROGRAMS
Definition: CStartMenu.cpp:39
#define IDM_DOCUMENTS
Definition: CStartMenu.cpp:37
#define CSIDL_RECENT
Definition: shlobj.h:2181
#define CSIDL_FAVORITES
Definition: shlobj.h:2179
#define CSIDL_PRINTERS
Definition: shlobj.h:2177
#define CSIDL_NETWORK
Definition: shlobj.h:2190
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175
#define CSIDL_CONTROLS
Definition: shlobj.h:2176

Referenced by OnGetContextMenu(), and OnGetSubMenu().

◆ GetAdvancedValue()

BOOL CShellMenuCallback::GetAdvancedValue ( LPCWSTR  pszName,
BOOL  bDefault = FALSE 
) const
inlineprivate

Definition at line 190 of file CStartMenu.cpp.

191 {
193 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
194 pszName, FALSE, bDefault);
195 }
BOOL WINAPI SHRegGetBoolUSValueW(LPCWSTR pszSubKey, LPCWSTR pszValue, BOOL fIgnoreHKCU, BOOL fDefault)
Definition: reg.c:770

Referenced by CreateRecentMenu(), and UpdateSettingsMenu().

◆ Initialize()

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

Definition at line 440 of file CStartMenu.cpp.

444 {
445 m_pShellMenu = pShellMenu;
446 m_pBandSite = pBandSite;
447 m_pDeskBar = pDeskBar;
448 }
CComPtr< IBandSite > m_pBandSite
Definition: CStartMenu.cpp:66
CComPtr< IDeskBar > m_pDeskBar
Definition: CStartMenu.cpp:67
CComPtr< IShellMenu > m_pShellMenu
Definition: CStartMenu.cpp:65

◆ OnExec()

HRESULT CShellMenuCallback::OnExec ( LPSMDATA  psmd)
inlineprivate

Definition at line 399 of file CStartMenu.cpp.

400 {
402
403 // HACK: Because our ShellExecute can't handle CLSID components in paths, we can't launch the paths using the "open" verb.
404 // FIXME: Change this back to using the path as the filename and the "open" verb, once ShellExecute can handle CLSID path components.
405
406 if (psmd->uId == IDM_CONTROLPANEL)
407 ShellExecuteW(NULL, NULL, L"explorer.exe", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}", NULL, SW_SHOWNORMAL);
408 else if (psmd->uId == IDM_NETWORKCONNECTIONS)
409 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);
410 else if (psmd->uId == IDM_PRINTERSANDFAXES)
411 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);
412 else if (psmd->uId == IDM_MYDOCUMENTS)
413 {
416 else
417 ERR("SHGetSpecialFolderPathW failed\n");
418 }
419 else if (psmd->uId == IDM_MYPICTURES)
420 {
423 else
424 ERR("SHGetSpecialFolderPathW failed\n");
425 }
426 else
428
429 return S_OK;
430 }
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
LPCWSTR szPath
Definition: env.c:37
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2492
#define CSIDL_PERSONAL
Definition: shlobj.h:2178
#define SW_SHOWNORMAL
Definition: winuser.h:773
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_COMMAND
Definition: winuser.h:1743
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CallbackSM().

◆ OnGetContextMenu()

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

Definition at line 366 of file CStartMenu.cpp.

367 {
368 INT csidl = CSIDLFromID(psmd->uId);
369 if (!csidl)
370 return S_FALSE;
371
372 TRACE("csidl: 0x%X\n", csidl);
373
374 if (csidl == CSIDL_CONTROLS || csidl == CSIDL_NETWORK || csidl == CSIDL_PRINTERS)
375 FIXME("This CSIDL %d wrongly opens My Computer. CORE-19477\n", csidl);
376
377 CComHeapPtr<ITEMIDLIST> pidl;
378 SHGetSpecialFolderLocation(NULL, csidl, &pidl);
379
380 CComPtr<IShellFolder> pSF;
381 LPCITEMIDLIST pidlChild = NULL;
382 HRESULT hr = SHBindToParent(pidl, IID_IShellFolder, (void**)&pSF, &pidlChild);
383 if (FAILED(hr))
384 return hr;
385
386 return pSF->GetUIObjectOf(NULL, 1, &pidlChild, IID_IContextMenu, NULL, pv);
387 }
#define FIXME(fmt,...)
Definition: precomp.h:53
INT CSIDLFromID(UINT uId) const
Definition: CStartMenu.cpp:350
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1356
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58

Referenced by OnGetObject().

◆ OnGetInfo()

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

Definition at line 103 of file CStartMenu.cpp.

104 {
105 int iconIndex = 0;
106
107 switch (psmd->uId)
108 {
109 // Smaller "24x24" icons used for the start menu
110 // The bitmaps are still 32x32, but the image is centered
111 case IDM_FAVORITES: iconIndex = -IDI_SHELL_FAVOTITES; break;
112 case IDM_SEARCH: iconIndex = -IDI_SHELL_SEARCH1; break;
113 case IDM_HELPANDSUPPORT: iconIndex = -IDI_SHELL_HELP2; break;
114 case IDM_LOGOFF: iconIndex = -IDI_SHELL_LOGOFF1; break;
115 case IDM_PROGRAMS: iconIndex = -IDI_SHELL_PROGRAMS_FOLDER1; break;
116 case IDM_DOCUMENTS: iconIndex = -IDI_SHELL_RECENT_DOCUMENTS1; break;
117 case IDM_RUN: iconIndex = -IDI_SHELL_RUN1; break;
118 case IDM_SHUTDOWN: iconIndex = -IDI_SHELL_SHUTDOWN1; break;
119 case IDM_SETTINGS: iconIndex = -IDI_SHELL_CONTROL_PANEL1; break;
120 case IDM_MYDOCUMENTS: iconIndex = -IDI_SHELL_MY_DOCUMENTS; break;
121 case IDM_MYPICTURES: iconIndex = -IDI_SHELL_MY_PICTURES; break;
122
123 case IDM_CONTROLPANEL: iconIndex = -IDI_SHELL_CONTROL_PANEL; break;
125 case IDM_PRINTERSANDFAXES: iconIndex = -IDI_SHELL_PRINTER2; break;
126 case IDM_TASKBARANDSTARTMENU: iconIndex = -IDI_SHELL_TSKBAR_STARTMENU; break;
127 //case IDM_SECURITY: iconIndex = -21; break;
128 //case IDM_SYNCHRONIZE: iconIndex = -21; break;
129 //case IDM_DISCONNECT: iconIndex = -21; break;
130 //case IDM_UNDOCKCOMPUTER: iconIndex = -21; break;
131 default:
132 return S_FALSE;
133 }
134
135 if (iconIndex)
136 {
137 if ((psminfo->dwMask & SMIM_TYPE) != 0)
138 psminfo->dwType = SMIT_STRING;
139 if ((psminfo->dwMask & SMIM_ICON) != 0)
140 psminfo->iIcon = Shell_GetCachedImageIndex(L"shell32.dll", iconIndex, FALSE);
141 if ((psminfo->dwMask & SMIM_FLAGS) != 0)
142 psminfo->dwFlags |= SMIF_ICON;
143#ifdef TEST_TRACKPOPUPMENU_SUBMENUS
144 if ((psminfo->dwMask & SMIM_FLAGS) != 0)
145 psminfo->dwFlags |= SMIF_TRACKPOPUP;
146#endif
147 }
148 else
149 {
150 if ((psminfo->dwMask & SMIM_TYPE) != 0)
151 psminfo->dwType = SMIT_SEPARATOR;
152 }
153 return S_OK;
154 }
#define IDM_SEARCH
Definition: CStartMenu.cpp:45
#define IDM_SHUTDOWN
Definition: CStartMenu.cpp:41
#define IDM_SETTINGS
Definition: CStartMenu.cpp:43
#define IDM_RUN
Definition: CStartMenu.cpp:32
#define IDM_HELPANDSUPPORT
Definition: CStartMenu.cpp:38
#define IDM_LOGOFF
Definition: CStartMenu.cpp:33
#define IDM_TASKBARANDSTARTMENU
Definition: CStartMenu.cpp:35
EXTERN_C INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:838
@ SMIM_TYPE
Definition: shobjidl.idl:2776
@ SMIM_ICON
Definition: shobjidl.idl:2778
@ SMIM_FLAGS
Definition: shobjidl.idl:2777
@ SMIF_ICON
Definition: shobjidl.idl:2789
@ SMIF_TRACKPOPUP
Definition: shobjidl.idl:2797
@ SMIT_STRING
Definition: shobjidl.idl:2784
@ SMIT_SEPARATOR
Definition: shobjidl.idl:2783
#define IDI_SHELL_MY_DOCUMENTS
Definition: shresdef.h:682
#define IDI_SHELL_SEARCH1
Definition: shresdef.h:766
#define IDI_SHELL_FAVOTITES
Definition: shresdef.h:765
#define IDI_SHELL_MY_PICTURES
Definition: shresdef.h:683
#define IDI_SHELL_TSKBAR_STARTMENU
Definition: shresdef.h:592
#define IDI_SHELL_PRINTER2
Definition: shresdef.h:611
#define IDI_SHELL_PROGRAMS_FOLDER1
Definition: shresdef.h:769
#define IDI_SHELL_CONTROL_PANEL1
Definition: shresdef.h:773
#define IDI_SHELL_LOGOFF1
Definition: shresdef.h:768
#define IDI_SHELL_RECENT_DOCUMENTS1
Definition: shresdef.h:770
#define IDI_SHELL_SHUTDOWN1
Definition: shresdef.h:772
#define IDI_SHELL_NETWORK_CONNECTIONS2
Definition: shresdef.h:704
#define IDI_SHELL_HELP2
Definition: shresdef.h:767
#define IDI_SHELL_CONTROL_PANEL
Definition: shresdef.h:574
#define IDI_SHELL_RUN1
Definition: shresdef.h:771
DWORD dwType
Definition: shobjidl.idl:2760
DWORD dwMask
Definition: shobjidl.idl:2759
DWORD dwFlags
Definition: shobjidl.idl:2761

Referenced by CallbackSM().

◆ OnGetObject()

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

Definition at line 389 of file CStartMenu.cpp.

390 {
391 if (IsEqualIID(iid, IID_IShellMenu))
392 return OnGetSubMenu(psmd, iid, pv);
393 else if (IsEqualIID(iid, IID_IContextMenu))
394 return OnGetContextMenu(psmd, iid, pv);
395
396 return S_FALSE;
397 }
HRESULT OnGetContextMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:366
HRESULT OnGetSubMenu(LPSMDATA psmd, REFIID iid, void **pv)
Definition: CStartMenu.cpp:273
#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 273 of file CStartMenu.cpp.

274 {
275 HRESULT hr;
276 CComPtr<IShellMenu> pShellMenu;
277
280 return hr;
281
282 hr = pShellMenu->Initialize(this, 0, ANCESTORDEFAULT, SMINIT_VERTICAL);
284 return hr;
285
286 hr = E_FAIL;
287 switch (psmd->uId)
288 {
289 case IDM_PROGRAMS:
290 {
291 hr = AddStartMenuItems(pShellMenu, CSIDL_PROGRAMS, SMSET_TOP, m_psfPrograms);
292 break;
293 }
294 case IDM_FAVORITES:
295 case IDM_MYDOCUMENTS:
296 case IDM_MYPICTURES:
297 case IDM_CONTROLPANEL:
300 {
301 hr = AddStartMenuItems(pShellMenu, CSIDLFromID(psmd->uId), SMSET_TOP);
302 break;
303 }
304 case IDM_DOCUMENTS:
305 {
306 HMENU hMenu = CreateRecentMenu();
307 if (hMenu == NULL)
308 ERR("CreateRecentMenu failed\n");
309
310 hr = pShellMenu->SetMenu(hMenu, NULL, SMSET_BOTTOM);
312 return hr;
313
314 hr = AddStartMenuItems(pShellMenu, CSIDL_RECENT, SMSET_BOTTOM);
315 break;
316 }
317 case IDM_SETTINGS:
318 {
319 MENUITEMINFOW mii = { sizeof(mii), MIIM_SUBMENU };
320 if (GetMenuItemInfoW(psmd->hmenu, psmd->uId, FALSE, &mii))
321 {
323
324 hr = pShellMenu->SetMenu(mii.hSubMenu, NULL, SMSET_BOTTOM);
326 return hr;
327 }
328 break;
329 }
330 default:
331 {
332 MENUITEMINFOW mii = { sizeof(mii), MIIM_SUBMENU };
333 if (GetMenuItemInfoW(psmd->hmenu, psmd->uId, FALSE, &mii))
334 {
335 hr = pShellMenu->SetMenu(mii.hSubMenu, NULL, SMSET_BOTTOM);
337 return hr;
338 }
339 }
340 }
341
342 if (FAILED(hr))
343 return hr;
344
345 hr = pShellMenu->QueryInterface(iid, pv);
346 pShellMenu.Detach();
347 return hr;
348 }
void UpdateSettingsMenu(HMENU hMenu)
Definition: CStartMenu.cpp:226
HMENU CreateRecentMenu() const
Definition: CStartMenu.cpp:197
HRESULT AddStartMenuItems(IShellMenu *pShellMenu, INT csidl, DWORD dwFlags, IShellFolder *psf=NULL)
Definition: CStartMenu.cpp:240
#define E_FAIL
Definition: ddrawi.h:102
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
HMENU hmenu
Definition: shobjidl.idl:2741
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)

Referenced by OnGetObject().

◆ OnInitMenu()

HRESULT CShellMenuCallback::OnInitMenu ( )
inlineprivate

Definition at line 73 of file CStartMenu.cpp.

74 {
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->AppendMenu(&hmenu);
91 return hr;
92
93 hr = m_pShellMenu->SetMenu(hmenu, NULL, SMSET_BOTTOM);
95 {
97 return hr;
98 }
99
100 return hr;
101 }
HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite)
Definition: ordinal.c:2642
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1336
static HMENU hmenu
Definition: win.c:66
BOOL WINAPI DestroyMenu(_In_ HMENU)

Referenced by CallbackSM().

◆ UpdateSettingsMenu()

void CShellMenuCallback::UpdateSettingsMenu ( HMENU  hMenu)
inlineprivate

Definition at line 226 of file CStartMenu.cpp.

227 {
228 BOOL bExpand;
229
230 bExpand = GetAdvancedValue(L"CascadeControlPanel");
232
233 bExpand = GetAdvancedValue(L"CascadeNetworkConnections");
235
236 bExpand = GetAdvancedValue(L"CascadePrinters");
238 }

Referenced by OnGetSubMenu().

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: