ReactOS 0.4.15-dev-7931-gfd331f1
CBandSiteMenu Class Reference

#include <CBandSiteMenu.h>

Inheritance diagram for CBandSiteMenu:
Collaboration diagram for CBandSiteMenu:

Public Member Functions

 CBandSiteMenu ()
 
 ~CBandSiteMenu ()
 
HRESULT WINAPI FinalConstruct ()
 
STDMETHOD() SetOwner (IUnknown *) override
 
STDMETHOD() QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override
 
STDMETHOD() InvokeCommand (LPCMINVOKECOMMANDINFO lpici) override
 
STDMETHOD() GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax) override
 
STDMETHOD() HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam) override
 
STDMETHOD() HandleMenuMsg2 (UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) override
 
- 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 HandleMenuMsg2 ([in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam, [out] LRESULT *plResult)
 
HRESULT HandleMenuMsg ([in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam)
 
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 ()
 
HRESULT SetOwner ([in] IUnknown *pUnk)
 

Private Member Functions

HRESULT _CreateMenuPart ()
 
HRESULT _CreateNewISFBand (HWND hwnd, REFIID riid, void **ppv)
 
LPITEMIDLIST _GetQLaunchPidl (BOOL refresh)
 
HRESULT _CreateBuiltInISFBand (UINT uID, REFIID riid, void **ppv)
 
HRESULT _AddISFBandToMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown *pBand, DWORD dwBandID, UINT *newMenuId)
 
UINT _GetMenuIdFromISFBand (IUnknown *pBand)
 
UINT _GetMenuIdFromBand (CLSID *BandCLSID)
 
UINT _GetBandIdFromClsid (CLSID *pclsid)
 
UINT _GetBandIdForBuiltinISFBand (UINT uID)
 
HRESULT _ShowToolbarError (HRESULT hRet)
 

Private Attributes

CComPtr< IBandSitem_BandSite
 
CSimpleArray< GUIDm_ComCatGuids
 
HMENU m_hmenu
 
CComHeapPtr< ITEMIDLISTm_DesktopPidl
 
CComHeapPtr< ITEMIDLISTm_QLaunchPidl
 

Additional Inherited Members

- Public Types inherited from IContextMenu3
typedef IContextMenu3LPCONTEXTMENU3
 
- Public Types inherited from IContextMenu2
typedef IContextMenu2LPCONTEXTMENU2
 
- 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::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 25 of file CBandSiteMenu.h.

Constructor & Destructor Documentation

◆ CBandSiteMenu()

CBandSiteMenu::CBandSiteMenu ( )

Definition at line 36 of file CBandSiteMenu.cpp.

36 :
40{
41}
CComHeapPtr< ITEMIDLIST > m_DesktopPidl
Definition: CBandSiteMenu.h:34
CComHeapPtr< ITEMIDLIST > m_QLaunchPidl
Definition: CBandSiteMenu.h:35
#define NULL
Definition: types.h:112

◆ ~CBandSiteMenu()

CBandSiteMenu::~CBandSiteMenu ( )

Definition at line 43 of file CBandSiteMenu.cpp.

44{
45 if (m_hmenu)
47
49}
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
BOOL WINAPI DestroyMenu(_In_ HMENU)

Member Function Documentation

◆ _AddISFBandToMenu()

HRESULT CBandSiteMenu::_AddISFBandToMenu ( HMENU  hmenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
IUnknown pBand,
DWORD  dwBandID,
UINT newMenuId 
)
private

Definition at line 226 of file CBandSiteMenu.cpp.

227{
228 CComPtr<IShellFolderBand> psfb;
229 HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
231 return hr;
232
234 hr = psfb->GetBandInfoSFB(&bi);
236 return hr;
237
238 CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
239 if (!pidl)
240 {
241 ERR("Failed to get the pidl of the CISFBand\n");
242 return E_OUTOFMEMORY;
243 }
244
248 return hr;
249
250 UINT id = idCmdFirst + m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID + dwBandID;
251 if (id >= idCmdLast)
252 return E_FAIL;
253
254 *newMenuId = id;
255 InsertMenu(hmenu, indexMenu, MF_BYPOSITION, id, buffer);
256 return S_OK;
257}
#define FIRST_COMCAT_MENU_ID
#define ERR(fmt,...)
Definition: debug.h:110
CSimpleArray< GUID > m_ComCatGuids
Definition: CBandSiteMenu.h:32
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
GLuint buffer
Definition: glext.h:5915
GLuint id
Definition: glext.h:5910
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
Definition: pidl.c:171
HRESULT hr
Definition: shlfolder.c:183
#define ISFB_MASK_IDLIST
Definition: shlobj.h:2770
PIDLIST_ABSOLUTE pidl
Definition: shlobj.h:2787
#define ILGDN_INFOLDER
Definition: undocshell.h:72
static HMENU hmenu
Definition: win.c:66
#define MF_BYPOSITION
Definition: winuser.h:203
#define InsertMenu
Definition: winuser.h:5803
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by QueryContextMenu().

◆ _CreateBuiltInISFBand()

HRESULT CBandSiteMenu::_CreateBuiltInISFBand ( UINT  uID,
REFIID  riid,
void **  ppv 
)
private

Definition at line 178 of file CBandSiteMenu.cpp.

179{
180 LPITEMIDLIST pidl;
181 HRESULT hr;
182
183 switch (uID)
184 {
186 {
187 if (m_DesktopPidl != NULL)
188 m_DesktopPidl.Free();
189
192 return hr;
193
194 pidl = m_DesktopPidl;
195 break;
196 }
198 {
199 pidl = _GetQLaunchPidl(true);
200 break;
201 }
202 }
203
204 if (pidl == NULL)
205 return E_FAIL;
206
207 CComPtr<IShellFolderBand> pISFB;
208 hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
210 return hr;
211
212 hr = pISFB->InitializeSFB(NULL, pidl);
214 return hr;
215
216 /* HACK! We shouldn't pass ISFB_STATE_QLINKSMODE and CISFBand shouldn't handle it! */
218 {
220 pISFB->SetBandInfoSFB(&bisfb);
221 }
222
223 return pISFB->QueryInterface(riid, ppv);
224}
LPITEMIDLIST _GetQLaunchPidl(BOOL refresh)
#define IDM_TASKBAR_TOOLBARS_DESKTOP
Definition: resource.h:59
#define IDM_TASKBAR_TOOLBARS_QUICKLAUNCH
Definition: resource.h:60
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3124
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define CISFBand_CreateInstance
Definition: shellbars.h:39
#define ISFB_MASK_STATE
Definition: shlobj.h:2769
#define ISFB_STATE_QLINKSMODE
Definition: shlobj.h:2772
#define CSIDL_DESKTOP
Definition: shlobj.h:2158
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeCommand().

◆ _CreateMenuPart()

HRESULT CBandSiteMenu::_CreateMenuPart ( )
private

Definition at line 56 of file CBandSiteMenu.cpp.

57{
58 WCHAR wszBandName[MAX_PATH];
59 WCHAR wszBandGUID[MAX_PATH];
60 WCHAR wRegKey[MAX_PATH];
61 UINT cBands;
62 CATID category = CATID_DeskBand;
63 HMENU hmenuToolbars;
64 DWORD dwRead, dwDataSize;
65 CComPtr<IEnumGUID> pEnumGUID;
66 HRESULT hr;
67
68 if (m_hmenu)
70
71 /* Load the template we will fill in */
73 if (!m_hmenu)
75
76 /* Get the handle of the submenu where the available items will be shown */
77 hmenuToolbars = GetSubMenu(m_hmenu, 0);
78
79 /* Create the category enumerator */
80 hr = SHEnumClassesOfCategories(1, &category, 0, NULL, &pEnumGUID);
82 return hr;
83
84 m_ComCatGuids.RemoveAll();
85
86 /* Enumerate the classes in the CATID_DeskBand category */
87 cBands = 0;
88 do
89 {
90 GUID iter;
91 pEnumGUID->Next(1, &iter, &dwRead);
92 if (!dwRead)
93 continue;
94
95 if (!StringFromGUID2(iter, wszBandGUID, MAX_PATH))
96 continue;
97
98 /* Get the band name */
99 StringCchPrintfW(wRegKey, MAX_PATH, L"CLSID\\%s", wszBandGUID);
100 HKEY hKey;
102 {
103 hr = SHLoadRegUIStringW(hKey, L"MenuTextPUI", wszBandName, _countof(wszBandName));
105 {
106 hr = SHLoadRegUIStringW(hKey, L"MenuText", wszBandName, _countof(wszBandName));
108 {
109 hr = SHLoadRegUIStringW(hKey, NULL, wszBandName, _countof(wszBandName));
111 }
112 }
114 }
115 else
116 {
117 dwDataSize = sizeof(wszBandName);
118 SHGetValueW(HKEY_CLASSES_ROOT, wRegKey, NULL, NULL, wszBandName, &dwDataSize);
119 }
120
121 /* Insert it */
122 InsertMenu(hmenuToolbars, cBands, MF_BYPOSITION, m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID, wszBandName);
123 m_ComCatGuids.Add(iter);
124 cBands++;
125 }
126 while (dwRead > 0);
127
128 return S_OK;
129}
HRESULT WINAPI SHEnumClassesOfCategories(ULONG cImplemented, CATID *pImplemented, ULONG cRequired, CATID *pRequired, IEnumGUID **out)
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define IDM_TASKBAR_TOOLBARS
Definition: resource.h:58
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
HRESULT WINAPI SHLoadRegUIStringW(HKEY hkey, LPCWSTR value, LPWSTR buf, DWORD size)
Definition: ordinal.c:4240
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)

Referenced by SetOwner().

◆ _CreateNewISFBand()

HRESULT CBandSiteMenu::_CreateNewISFBand ( HWND  hwnd,
REFIID  riid,
void **  ppv 
)
private

Definition at line 131 of file CBandSiteMenu.cpp.

132{
134 WCHAR message[256];
135 BROWSEINFOW bi = { hwnd, NULL, path };
136
138 bi.lpszTitle = message;
139 else
140 bi.lpszTitle = L"Choose a folder";
141
142 CComHeapPtr<ITEMIDLIST> pidlSelected;
143 pidlSelected.Attach(SHBrowseForFolderW(&bi));
144 if (pidlSelected == NULL)
145 return S_FALSE;
146
147 CComPtr<IShellFolderBand> pISFB;
148 HRESULT hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
150 return hr;
151
152 hr = pISFB->InitializeSFB(NULL, pidlSelected);
154 return hr;
155
156 return pISFB->QueryInterface(riid, ppv);
157}
#define IDS_BROWSEFORNEWTOOLAR
Definition: resource.h:119
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1419
Definition: tftpd.h:60
LPCWSTR lpszTitle
Definition: shlobj.h:1196
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define S_FALSE
Definition: winerror.h:2357
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by InvokeCommand().

◆ _GetBandIdForBuiltinISFBand()

UINT CBandSiteMenu::_GetBandIdForBuiltinISFBand ( UINT  uID)
private

Definition at line 323 of file CBandSiteMenu.cpp.

324{
325 CComPtr<IPersist> pBand;
326 CLSID BandCLSID;
327 DWORD dwBandID;
328
329 for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
330 {
331 if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
332 continue;
333
334 if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
335 continue;
336
337 if (!IsEqualGUID(BandCLSID, CLSID_ISFBand))
338 continue;
339
340 UINT menuID = _GetMenuIdFromISFBand(pBand);
341 if (menuID == uID)
342 return dwBandID;
343 }
344
345 return UINT_MAX;
346}
UINT _GetMenuIdFromISFBand(IUnknown *pBand)
#define UINT_MAX
Definition: limits.h:41
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by InvokeCommand().

◆ _GetBandIdFromClsid()

UINT CBandSiteMenu::_GetBandIdFromClsid ( CLSID pclsid)
private

Definition at line 302 of file CBandSiteMenu.cpp.

303{
304 CComPtr<IPersist> pBand;
305 CLSID BandCLSID;
306 DWORD dwBandID;
307
308 for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
309 {
310 if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
311 continue;
312
313 if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
314 continue;
315
316 if (IsEqualGUID(*pclsid, BandCLSID))
317 return dwBandID;
318 }
319
320 return UINT_MAX;
321}

Referenced by InvokeCommand().

◆ _GetMenuIdFromBand()

UINT CBandSiteMenu::_GetMenuIdFromBand ( CLSID BandCLSID)
private

◆ _GetMenuIdFromISFBand()

UINT CBandSiteMenu::_GetMenuIdFromISFBand ( IUnknown pBand)
private

Definition at line 259 of file CBandSiteMenu.cpp.

260{
261 CComPtr<IShellFolderBand> psfb;
262 HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
264 return UINT_MAX;
265
267 hr = psfb->GetBandInfoSFB(&bi);
269 return UINT_MAX;
270
271 CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
272 if (!pidl)
273 {
274 ERR("Failed to get the pidl of the CISFBand\n");
275 return UINT_MAX;
276 }
277
278 if (pidl->mkid.cb == 0)
279 {
281 }
282
283 CComPtr<IShellFolder> psfDesktop;
284 hr = SHGetDesktopFolder(&psfDesktop);
286 return UINT_MAX;
287
288 LPITEMIDLIST _QLaunchPidl = _GetQLaunchPidl(false);
289 if (_QLaunchPidl == NULL)
290 return UINT_MAX;
291
292 hr = psfDesktop->CompareIDs(0, pidl, _QLaunchPidl);
294 return UINT_MAX;
295
296 if (HRESULT_CODE(hr) == 0)
298
299 return UINT_MAX;
300}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define HRESULT_CODE(hr)
Definition: winerror.h:76

Referenced by _GetBandIdForBuiltinISFBand(), and QueryContextMenu().

◆ _GetQLaunchPidl()

LPITEMIDLIST CBandSiteMenu::_GetQLaunchPidl ( BOOL  refresh)
private

Definition at line 159 of file CBandSiteMenu.cpp.

160{
161 if (m_QLaunchPidl != NULL)
162 {
163 if (refresh)
164 m_QLaunchPidl.Free();
165 else
166 return m_QLaunchPidl;
167 }
168
170 HRESULT hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA, NULL, 0, L"Microsoft\\Internet Explorer\\Quick Launch", buffer);
172 return NULL;
173
175 return m_QLaunchPidl;
176}
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2654
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:995
#define CSIDL_APPDATA
Definition: shlobj.h:2183

Referenced by _CreateBuiltInISFBand(), and _GetMenuIdFromISFBand().

◆ _ShowToolbarError()

HRESULT CBandSiteMenu::_ShowToolbarError ( HRESULT  hRet)
private

Definition at line 408 of file CBandSiteMenu.cpp.

409{
410 WCHAR szText[260];
411 WCHAR szTitle[256];
412
413 if (!LoadStringW(GetModuleHandleW(L"browseui.dll"), IDS_TOOLBAR_ERR_TEXT, szText, _countof(szText)))
414 StringCchCopyW(szText, _countof(szText), L"Cannot create toolbar.");
415
418
420 return hRet;
421}
#define IDS_TOOLBAR_ERR_TEXT
Definition: resource.h:121
#define IDS_TOOLBAR_ERR_TITLE
Definition: resource.h:120
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define MB_SETFOREGROUND
Definition: winuser.h:814
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790
#define MB_ICONSTOP
Definition: winuser.h:803

Referenced by InvokeCommand().

◆ FinalConstruct()

HRESULT WINAPI CBandSiteMenu::FinalConstruct ( )

Definition at line 51 of file CBandSiteMenu.cpp.

52{
53 return S_OK;
54}

◆ GetCommandString()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::GetCommandString ( UINT_PTR  idCmd,
UINT  uType,
UINT pwReserved,
LPSTR  pszName,
UINT  cchMax 
)
override

Implements IContextMenu.

Definition at line 503 of file CBandSiteMenu.cpp.

505{
506 FIXME("CBandSiteMenu::GetCommandString is UNIMPLEMENTED (%p, %p, %u, %p, %p, %u)\n", this, idCmd, uType, pwReserved, pszName, cchMax);
507 return E_NOTIMPL;
508}
UINT cchMax
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ HandleMenuMsg()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::HandleMenuMsg ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
override

Implements IContextMenu2.

Definition at line 510 of file CBandSiteMenu.cpp.

511{
512 FIXME("CBandSiteMenu::HandleMenuMsg is UNIMPLEMENTED (%p, %u, %p, %p)\n", this, uMsg, wParam, lParam);
513 return E_NOTIMPL;
514}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

◆ HandleMenuMsg2()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::HandleMenuMsg2 ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT plResult 
)
override

Implements IContextMenu3.

Definition at line 516 of file CBandSiteMenu.cpp.

517{
518 FIXME("CBandSiteMenu::HandleMenuMsg2 is UNIMPLEMENTED(%p, %u, %p, %p, %p)\n", this, uMsg, wParam, lParam, plResult);
519 return E_NOTIMPL;
520}

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
override

Implements IContextMenu.

Definition at line 423 of file CBandSiteMenu.cpp.

424{
425 HRESULT hRet;
426 DWORD dwBandID;
427
428 /* FIXME: do we need to handle this and how? */
429 if (HIWORD(lpici->lpVerb) != NULL)
430 return E_FAIL;
431
432 UINT uID = LOWORD(lpici->lpVerb);
433 if (uID == IDM_TASKBAR_TOOLBARS_NEW)
434 {
435 CComPtr<IDeskBand> pDeskBand;
436 hRet = _CreateNewISFBand(lpici->hwnd, IID_PPV_ARG(IDeskBand, &pDeskBand));
437 if (FAILED_UNEXPECTEDLY(hRet))
438 return hRet;
439
440 hRet = m_BandSite->AddBand(pDeskBand);
441 if (FAILED_UNEXPECTEDLY(hRet))
442 return hRet;
443
444 return S_OK;
445 }
446 else if (uID > (UINT) m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID )
447 {
448 dwBandID = uID - (m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID );
449
450 m_BandSite->RemoveBand(dwBandID);
451
452 return S_OK;
453 }
455 {
456 dwBandID = _GetBandIdForBuiltinISFBand(uID);
457 if (dwBandID != UINT_MAX)
458 {
459 m_BandSite->RemoveBand(dwBandID);
460 }
461 else
462 {
463 CComPtr<IDeskBand> pDeskBand;
464 hRet = _CreateBuiltInISFBand(uID, IID_PPV_ARG(IDeskBand, &pDeskBand));
465 if (FAILED_UNEXPECTEDLY(hRet))
466 return _ShowToolbarError(hRet);
467
468 hRet = m_BandSite->AddBand(pDeskBand);
469 if (FAILED_UNEXPECTEDLY(hRet))
470 return _ShowToolbarError(hRet);
471 }
472 return S_OK;
473 }
474
475 /* Get the GUID of the item that was clicked */
476 GUID *pguidToolbar = &m_ComCatGuids[uID - FIRST_COMCAT_MENU_ID];
477 if (!pguidToolbar)
478 return E_FAIL;
479
480 /* Try to find if a band with a guid is present. If it is, remove it and return */
481 dwBandID = _GetBandIdFromClsid(pguidToolbar);
482 if (dwBandID != UINT_MAX)
483 {
484 /* We found it, remove it */
485 m_BandSite->RemoveBand(dwBandID);
486 }
487 else
488 {
489 /* It is not present. Add it. */
490 CComPtr<IDeskBand> pDeskBand;
491 hRet = CoCreateInstance(*pguidToolbar, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IDeskBand, &pDeskBand));
492 if (FAILED_UNEXPECTEDLY(hRet))
493 return hRet;
494
495 hRet = m_BandSite->AddBand(pDeskBand);
496 if (FAILED_UNEXPECTEDLY(hRet))
497 return hRet;
498 }
499
500 return S_OK;
501}
UINT _GetBandIdFromClsid(CLSID *pclsid)
HRESULT _ShowToolbarError(HRESULT hRet)
HRESULT _CreateNewISFBand(HWND hwnd, REFIID riid, void **ppv)
UINT _GetBandIdForBuiltinISFBand(UINT uID)
HRESULT _CreateBuiltInISFBand(UINT uID, REFIID riid, void **ppv)
#define IDM_TASKBAR_TOOLBARS_NEW
Definition: resource.h:61
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247

◆ QueryContextMenu()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::QueryContextMenu ( HMENU  hmenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
override

Implements IContextMenu.

Definition at line 358 of file CBandSiteMenu.cpp.

360{
361 CComPtr<IPersist> pBand;
362 CLSID BandCLSID;
363 DWORD dwBandID;
364 UINT idMax;
365
366 TRACE("CBandSiteMenu::QueryContextMenu(%p, %p, %u, %u, %u, 0x%x)\n", this, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
367
368 /* First Merge the menu with the available bands */
369 idMax = Shell_MergeMenus(hmenu, m_hmenu, indexMenu, idCmdFirst, idCmdLast, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS);
370
371 HMENU hmenuToolbars = GetSubMenu(hmenu, indexMenu);
372
373 /* Enumerate all present bands and mark them as checked in the menu */
374 for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
375 {
376 if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
377 continue;
378
379 if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
380 continue;
381
382 UINT menuID;
383 if (IsEqualGUID(BandCLSID, CLSID_ISFBand))
384 {
385 menuID = _GetMenuIdFromISFBand(pBand);
386 if (menuID == UINT_MAX)
387 {
388 HRESULT hr;
389 hr = _AddISFBandToMenu(hmenuToolbars, 0, idCmdFirst, idCmdLast, pBand, dwBandID, &menuID);
390 if (SUCCEEDED(hr) && menuID > idMax)
391 idMax = menuID;
392 menuID -= idCmdFirst;
393 }
394 }
395 else
396 {
397 int i = m_ComCatGuids.Find(BandCLSID);
398 menuID = (i == -1 ? UINT_MAX : i + FIRST_COMCAT_MENU_ID);
399 }
400
401 if (menuID != UINT_MAX)
402 CheckMenuItem(hmenuToolbars, menuID + idCmdFirst, MF_CHECKED);
403 }
404
405 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(idMax - idCmdFirst +1));
406}
HRESULT _AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown *pBand, DWORD dwBandID, UINT *newMenuId)
UINT uFlags
Definition: api.c:59
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:856
#define MM_SUBMENUSHAVEIDS
Definition: shlobj.h:2514
#define MM_DONTREMOVESEPS
Definition: shlobj.h:2515
#define TRACE(s)
Definition: solgame.cpp:4
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MF_CHECKED
Definition: winuser.h:132
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)

◆ SetOwner()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::SetOwner ( IUnknown pOwner)
override

Implements IShellService.

Definition at line 348 of file CBandSiteMenu.cpp.

349{
350 TRACE("CBandSiteMenu::SetOwner(%p, %p)\n", this, pOwner);
351
352 /* Cache the menu that will be merged every time QueryContextMenu is called */
354
356}
HRESULT _CreateMenuPart()

Member Data Documentation

◆ m_BandSite

CComPtr<IBandSite> CBandSiteMenu::m_BandSite
private

◆ m_ComCatGuids

CSimpleArray<GUID> CBandSiteMenu::m_ComCatGuids
private

◆ m_DesktopPidl

CComHeapPtr<ITEMIDLIST> CBandSiteMenu::m_DesktopPidl
private

Definition at line 34 of file CBandSiteMenu.h.

Referenced by _CreateBuiltInISFBand().

◆ m_hmenu

HMENU CBandSiteMenu::m_hmenu
private

Definition at line 33 of file CBandSiteMenu.h.

Referenced by _CreateMenuPart(), QueryContextMenu(), and ~CBandSiteMenu().

◆ m_QLaunchPidl

CComHeapPtr<ITEMIDLIST> CBandSiteMenu::m_QLaunchPidl
private

Definition at line 35 of file CBandSiteMenu.h.

Referenced by _GetQLaunchPidl().


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