ReactOS  0.4.14-dev-384-g5b37caa
CBandSiteMenu Class Reference

#include <CBandSiteMenu.h>

Inheritance diagram for CBandSiteMenu:
Collaboration diagram for CBandSiteMenu:

Public Member Functions

 CBandSiteMenu ()
 
 ~CBandSiteMenu ()
 
HRESULT WINAPI FinalConstruct ()
 
virtual HRESULT STDMETHODCALLTYPE SetOwner (IUnknown *)
 
virtual HRESULT STDMETHODCALLTYPE QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT STDMETHODCALLTYPE InvokeCommand (LPCMINVOKECOMMANDINFO lpici)
 
virtual HRESULT STDMETHODCALLTYPE GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
 
virtual HRESULT STDMETHODCALLTYPE HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual HRESULT STDMETHODCALLTYPE HandleMenuMsg2 (UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
 
- 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 _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 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
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 25 of file CBandSiteMenu.h.

Constructor & Destructor Documentation

◆ CBandSiteMenu()

CBandSiteMenu::CBandSiteMenu ( )

Definition at line 35 of file CBandSiteMenu.cpp.

35  :
36  m_hmenu(NULL),
39 {
40 }
smooth NULL
Definition: ftsmooth.c:416
CComHeapPtr< ITEMIDLIST > m_DesktopPidl
Definition: CBandSiteMenu.h:34
CComHeapPtr< ITEMIDLIST > m_QLaunchPidl
Definition: CBandSiteMenu.h:35

◆ ~CBandSiteMenu()

CBandSiteMenu::~CBandSiteMenu ( )

Definition at line 42 of file CBandSiteMenu.cpp.

43 {
44  if (m_hmenu)
46 
47  m_BandSite = NULL;
48 }
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
smooth NULL
Definition: ftsmooth.c:416
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 208 of file CBandSiteMenu.cpp.

209 {
210  CComPtr<IShellFolderBand> psfb;
211  HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
212  if (FAILED_UNEXPECTEDLY(hr))
213  return hr;
214 
216  hr = psfb->GetBandInfoSFB(&bi);
217  if (FAILED_UNEXPECTEDLY(hr))
218  return hr;
219 
220  CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
221  if (!pidl)
222  {
223  ERR("Failed to get the pidl of the CISFBand\n");
224  return E_OUTOFMEMORY;
225  }
226 
229  if (FAILED_UNEXPECTEDLY(hr))
230  return hr;
231 
232  UINT id = idCmdFirst + m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID + dwBandID;
233  if (id >= idCmdLast)
234  return E_FAIL;
235 
236  *newMenuId = id;
237  InsertMenu(hmenu, indexMenu, MF_BYPOSITION, id, buffer);
238  return S_OK;
239 }
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
#define InsertMenu
Definition: winuser.h:5704
#define FIRST_COMCAT_MENU_ID
GLuint buffer
Definition: glext.h:5915
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
CSimpleArray< GUID > m_ComCatGuids
Definition: CBandSiteMenu.h:32
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
PIDLIST_ABSOLUTE pidl
Definition: shlobj.h:2571
#define MF_BYPOSITION
Definition: winuser.h:203
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
#define ILGDN_INFOLDER
Definition: undocshell.h:70
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
Definition: pidl.c:162
unsigned int UINT
Definition: ndis.h:50
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define ISFB_MASK_IDLIST
Definition: shlobj.h:2554
GLenum GLuint id
Definition: glext.h:5579

Referenced by QueryContextMenu().

◆ _CreateBuiltInISFBand()

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

Definition at line 160 of file CBandSiteMenu.cpp.

161 {
162  LPITEMIDLIST pidl;
163  HRESULT hr;
164 
165  switch (uID)
166  {
168  {
169  if (m_DesktopPidl != NULL)
170  m_DesktopPidl.Free();
171 
173  if (FAILED_UNEXPECTEDLY(hr))
174  return hr;
175 
176  pidl = m_DesktopPidl;
177  break;
178  }
180  {
181  pidl = _GetQLaunchPidl(true);
182  break;
183  }
184  }
185 
186  if (pidl == NULL)
187  return E_FAIL;
188 
189  CComPtr<IShellFolderBand> pISFB;
190  hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
191  if (FAILED_UNEXPECTEDLY(hr))
192  return hr;
193 
194  hr = pISFB->InitializeSFB(NULL, pidl);
195  if (FAILED_UNEXPECTEDLY(hr))
196  return hr;
197 
198  /* HACK! We shouldn't pass ISFB_STATE_QLINKSMODE and CISFBand shouldn't handle it! */
200  {
202  pISFB->SetBandInfoSFB(&bisfb);
203  }
204 
205  return pISFB->QueryInterface(riid, ppv);
206 }
LPITEMIDLIST _GetQLaunchPidl(BOOL refresh)
#define ISFB_STATE_QLINKSMODE
Definition: shlobj.h:2556
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
REFIID riid
Definition: precomp.h:44
#define CISFBand_CreateInstance
Definition: shellbars.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
#define ISFB_MASK_STATE
Definition: shlobj.h:2553
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define IDM_TASKBAR_TOOLBARS_QUICKLAUNCH
Definition: resource.h:60
#define IDM_TASKBAR_TOOLBARS_DESKTOP
Definition: resource.h:59
CComHeapPtr< ITEMIDLIST > m_DesktopPidl
Definition: CBandSiteMenu.h:34
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2672
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeCommand().

◆ _CreateMenuPart()

HRESULT CBandSiteMenu::_CreateMenuPart ( )
private

Definition at line 55 of file CBandSiteMenu.cpp.

56 {
57  WCHAR wszBandName[MAX_PATH];
58  WCHAR wszBandGUID[MAX_PATH];
59  WCHAR wRegKey[MAX_PATH];
60  UINT cBands;
61  DWORD dwDataSize;
62  CATID category = CATID_DeskBand;
63  HMENU hmenuToolbars;
64  DWORD dwRead;
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  dwDataSize = MAX_PATH;
101  SHGetValue(HKEY_CLASSES_ROOT, wRegKey, NULL, NULL, wszBandName, &dwDataSize);
102 
103  /* Insert it */
104  InsertMenu(hmenuToolbars, cBands, MF_BYPOSITION, m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID, wszBandName);
105  m_ComCatGuids.Add(iter);
106  cBands++;
107  }
108  while (dwRead > 0);
109 
110  return S_OK;
111 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define InsertMenu
Definition: winuser.h:5704
#define IDM_TASKBAR_TOOLBARS
Definition: resource.h:58
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FIRST_COMCAT_MENU_ID
CSimpleArray< GUID > m_ComCatGuids
Definition: CBandSiteMenu.h:32
#define MF_BYPOSITION
Definition: winuser.h:203
HRESULT WINAPI SHEnumClassesOfCategories(ULONG cImplemented, CATID *pImplemented, ULONG cRequired, CATID *pRequired, IEnumGUID **out)
smooth NULL
Definition: ftsmooth.c:416
#define SHGetValue
Definition: shlwapi.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define S_OK
Definition: intsafe.h:59
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by SetOwner().

◆ _CreateNewISFBand()

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

Definition at line 113 of file CBandSiteMenu.cpp.

114 {
116  WCHAR message[256];
117  BROWSEINFOW bi = { hwnd, NULL, path };
118 
120  bi.lpszTitle = message;
121  else
122  bi.lpszTitle = L"Choose a folder";
123 
124  CComHeapPtr<ITEMIDLIST> pidlSelected;
125  pidlSelected.Attach(SHBrowseForFolderW(&bi));
126  if (pidlSelected == NULL)
127  return S_FALSE;
128 
129  CComPtr<IShellFolderBand> pISFB;
130  HRESULT hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
131  if (FAILED_UNEXPECTEDLY(hr))
132  return hr;
133 
134  hr = pISFB->InitializeSFB(NULL, pidlSelected);
135  if (FAILED_UNEXPECTEDLY(hr))
136  return hr;
137 
138  return pISFB->QueryInterface(riid, ppv);
139 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define _countof(array)
Definition: fontsub.cpp:30
#define CISFBand_CreateInstance
Definition: shellbars.h:39
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
REFIID LPVOID * ppv
Definition: atlbase.h:39
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDS_BROWSEFORNEWTOOLAR
Definition: resource.h:116
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszTitle
Definition: shlobj.h:1121
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1156
Definition: services.c:325
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847

Referenced by InvokeCommand().

◆ _GetBandIdForBuiltinISFBand()

UINT CBandSiteMenu::_GetBandIdForBuiltinISFBand ( UINT  uID)
private

Definition at line 305 of file CBandSiteMenu.cpp.

306 {
307  CComPtr<IPersist> pBand;
308  CLSID BandCLSID;
309  DWORD dwBandID;
310 
311  for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
312  {
313  if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
314  continue;
315 
316  if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
317  continue;
318 
319  if (!IsEqualGUID(BandCLSID, CLSID_ISFBand))
320  continue;
321 
322  UINT menuID = _GetMenuIdFromISFBand(pBand);
323  if (menuID == uID)
324  return dwBandID;
325  }
326 
327  return UINT_MAX;
328 }
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
#define IID_PPV_ARG(Itype, ppType)
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define UINT_MAX
Definition: limits.h:41
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
UINT _GetMenuIdFromISFBand(IUnknown *pBand)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by InvokeCommand().

◆ _GetBandIdFromClsid()

UINT CBandSiteMenu::_GetBandIdFromClsid ( CLSID pclsid)
private

Definition at line 284 of file CBandSiteMenu.cpp.

285 {
286  CComPtr<IPersist> pBand;
287  CLSID BandCLSID;
288  DWORD dwBandID;
289 
290  for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
291  {
292  if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
293  continue;
294 
295  if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
296  continue;
297 
298  if (IsEqualGUID(*pclsid, BandCLSID))
299  return dwBandID;
300  }
301 
302  return UINT_MAX;
303 }
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
#define IID_PPV_ARG(Itype, ppType)
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define UINT_MAX
Definition: limits.h:41
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by InvokeCommand().

◆ _GetMenuIdFromBand()

UINT CBandSiteMenu::_GetMenuIdFromBand ( CLSID BandCLSID)
private

◆ _GetMenuIdFromISFBand()

UINT CBandSiteMenu::_GetMenuIdFromISFBand ( IUnknown pBand)
private

Definition at line 241 of file CBandSiteMenu.cpp.

242 {
243  CComPtr<IShellFolderBand> psfb;
244  HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
245  if (FAILED_UNEXPECTEDLY(hr))
246  return UINT_MAX;
247 
249  hr = psfb->GetBandInfoSFB(&bi);
250  if (FAILED_UNEXPECTEDLY(hr))
251  return UINT_MAX;
252 
253  CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
254  if (!pidl)
255  {
256  ERR("Failed to get the pidl of the CISFBand\n");
257  return UINT_MAX;
258  }
259 
260  if (pidl->mkid.cb == 0)
261  {
263  }
264 
265  CComPtr<IShellFolder> psfDesktop;
266  hr = SHGetDesktopFolder(&psfDesktop);
267  if (FAILED_UNEXPECTEDLY(hr))
268  return UINT_MAX;
269 
270  LPITEMIDLIST _QLaunchPidl = _GetQLaunchPidl(false);
271  if (_QLaunchPidl == NULL)
272  return UINT_MAX;
273 
274  hr = psfDesktop->CompareIDs(0, pidl, _QLaunchPidl);
275  if (FAILED_UNEXPECTEDLY(hr))
276  return UINT_MAX;
277 
278  if (HRESULT_CODE(hr) == 0)
280 
281  return UINT_MAX;
282 }
LPITEMIDLIST _GetQLaunchPidl(BOOL refresh)
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
PIDLIST_ABSOLUTE pidl
Definition: shlobj.h:2571
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define IDM_TASKBAR_TOOLBARS_QUICKLAUNCH
Definition: resource.h:60
#define ERR(fmt,...)
Definition: debug.h:109
#define UINT_MAX
Definition: limits.h:41
#define IDM_TASKBAR_TOOLBARS_DESKTOP
Definition: resource.h:59
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define ISFB_MASK_IDLIST
Definition: shlobj.h:2554
#define HRESULT_CODE(hr)
Definition: winerror.h:76
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by _GetBandIdForBuiltinISFBand(), and QueryContextMenu().

◆ _GetQLaunchPidl()

LPITEMIDLIST CBandSiteMenu::_GetQLaunchPidl ( BOOL  refresh)
private

Definition at line 141 of file CBandSiteMenu.cpp.

142 {
143  if (m_QLaunchPidl != NULL)
144  {
145  if (refresh)
146  m_QLaunchPidl.Free();
147  else
148  return m_QLaunchPidl;
149  }
150 
152  HRESULT hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA, NULL, 0, L"Microsoft\\Internet Explorer\\Quick Launch", buffer);
153  if (FAILED_UNEXPECTEDLY(hr))
154  return NULL;
155 
157  return m_QLaunchPidl;
158 }
HRESULT hr
Definition: shlfolder.c:183
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define CSIDL_APPDATA
Definition: shlobj.h:2028
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:982
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2219
CComHeapPtr< ITEMIDLIST > m_QLaunchPidl
Definition: CBandSiteMenu.h:35

Referenced by _CreateBuiltInISFBand(), and _GetMenuIdFromISFBand().

◆ _ShowToolbarError()

HRESULT CBandSiteMenu::_ShowToolbarError ( HRESULT  hRet)
private

Definition at line 390 of file CBandSiteMenu.cpp.

391 {
392  WCHAR szText[260];
393  WCHAR szTitle[256];
394 
396  StringCchCopyW(szText, _countof(szText), L"Cannot create toolbar.");
397 
399  StringCchCopyW(szTitle, _countof(szTitle), L"Toolbar");
400 
402  return hRet;
403 }
#define IDS_TOOLBAR_ERR_TEXT
Definition: resource.h:118
#define _countof(array)
Definition: fontsub.cpp:30
#define MB_ICONSTOP
Definition: winuser.h:797
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static const WCHAR szText[]
Definition: dialog.c:139
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static const WCHAR L[]
Definition: oid.c:1250
#define MB_OK
Definition: winuser.h:784
#define IDS_TOOLBAR_ERR_TITLE
Definition: resource.h:117
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
#define MB_SETFOREGROUND
Definition: winuser.h:808

Referenced by InvokeCommand().

◆ FinalConstruct()

HRESULT WINAPI CBandSiteMenu::FinalConstruct ( )

Definition at line 50 of file CBandSiteMenu.cpp.

51 {
52  return S_OK;
53 }
#define S_OK
Definition: intsafe.h:59

◆ GetCommandString()

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

Implements IContextMenu.

Definition at line 485 of file CBandSiteMenu.cpp.

487 {
488  FIXME("CBandSiteMenu::GetCommandString is UNIMPLEMENTED (%p, %p, %u, %p, %p, %u)\n", this, idCmd, uType, pwReserved, pszName, cchMax);
489  return E_NOTIMPL;
490 }
#define FIXME(fmt,...)
Definition: debug.h:110
UINT cchMax
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ HandleMenuMsg()

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

Implements IContextMenu2.

Definition at line 492 of file CBandSiteMenu.cpp.

493 {
494  FIXME("CBandSiteMenu::HandleMenuMsg is UNIMPLEMENTED (%p, %u, %p, %p)\n", this, uMsg, wParam, lParam);
495  return E_NOTIMPL;
496 }
WPARAM wParam
Definition: combotst.c:138
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
LPARAM lParam
Definition: combotst.c:139

◆ HandleMenuMsg2()

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

Implements IContextMenu3.

Definition at line 498 of file CBandSiteMenu.cpp.

499 {
500  FIXME("CBandSiteMenu::HandleMenuMsg2 is UNIMPLEMENTED(%p, %u, %p, %p, %p)\n", this, uMsg, wParam, lParam, plResult);
501  return E_NOTIMPL;
502 }
WPARAM wParam
Definition: combotst.c:138
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
LPARAM lParam
Definition: combotst.c:139

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
virtual

Implements IContextMenu.

Definition at line 405 of file CBandSiteMenu.cpp.

406 {
407  HRESULT hRet;
408  DWORD dwBandID;
409 
410  /* FIXME: do we need to handle this and how? */
411  if (HIWORD(lpici->lpVerb) != NULL)
412  return E_FAIL;
413 
414  UINT uID = LOWORD(lpici->lpVerb);
415  if (uID == IDM_TASKBAR_TOOLBARS_NEW)
416  {
417  CComPtr<IDeskBand> pDeskBand;
418  hRet = _CreateNewISFBand(lpici->hwnd, IID_PPV_ARG(IDeskBand, &pDeskBand));
419  if (FAILED_UNEXPECTEDLY(hRet))
420  return hRet;
421 
422  hRet = m_BandSite->AddBand(pDeskBand);
423  if (FAILED_UNEXPECTEDLY(hRet))
424  return hRet;
425 
426  return S_OK;
427  }
428  else if (uID > (UINT) m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID )
429  {
430  dwBandID = uID - (m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID );
431 
432  m_BandSite->RemoveBand(dwBandID);
433 
434  return S_OK;
435  }
437  {
438  dwBandID = _GetBandIdForBuiltinISFBand(uID);
439  if (dwBandID != UINT_MAX)
440  {
441  m_BandSite->RemoveBand(dwBandID);
442  }
443  else
444  {
445  CComPtr<IDeskBand> pDeskBand;
446  hRet = _CreateBuiltInISFBand(uID, IID_PPV_ARG(IDeskBand, &pDeskBand));
447  if (FAILED_UNEXPECTEDLY(hRet))
448  return _ShowToolbarError(hRet);
449 
450  hRet = m_BandSite->AddBand(pDeskBand);
451  if (FAILED_UNEXPECTEDLY(hRet))
452  return _ShowToolbarError(hRet);
453  }
454  return S_OK;
455  }
456 
457  /* Get the GUID of the item that was clicked */
458  GUID *pguidToolbar = &m_ComCatGuids[uID - FIRST_COMCAT_MENU_ID];
459  if (!pguidToolbar)
460  return E_FAIL;
461 
462  /* Try to find if a band with a guid is present. If it is, remove it and return */
463  dwBandID = _GetBandIdFromClsid(pguidToolbar);
464  if (dwBandID != UINT_MAX)
465  {
466  /* We found it, remove it */
467  m_BandSite->RemoveBand(dwBandID);
468  }
469  else
470  {
471  /* It is not present. Add it. */
472  CComPtr<IDeskBand> pDeskBand;
473  hRet = CoCreateInstance(*pguidToolbar, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IDeskBand, &pDeskBand));
474  if (FAILED_UNEXPECTEDLY(hRet))
475  return hRet;
476 
477  hRet = m_BandSite->AddBand(pDeskBand);
478  if (FAILED_UNEXPECTEDLY(hRet))
479  return hRet;
480  }
481 
482  return S_OK;
483 }
UINT _GetBandIdFromClsid(CLSID *pclsid)
HRESULT _CreateNewISFBand(HWND hwnd, REFIID riid, void **ppv)
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
#define IDM_TASKBAR_TOOLBARS_NEW
Definition: resource.h:61
#define FIRST_COMCAT_MENU_ID
HRESULT _CreateBuiltInISFBand(UINT uID, REFIID riid, void **ppv)
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
CSimpleArray< GUID > m_ComCatGuids
Definition: CBandSiteMenu.h:32
smooth NULL
Definition: ftsmooth.c:416
UINT _GetBandIdForBuiltinISFBand(UINT uID)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT _ShowToolbarError(HRESULT hRet)
#define IDM_TASKBAR_TOOLBARS_QUICKLAUNCH
Definition: resource.h:60
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define UINT_MAX
Definition: limits.h:41
#define S_OK
Definition: intsafe.h:59
#define IDM_TASKBAR_TOOLBARS_DESKTOP
Definition: resource.h:59
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:246
#define LOWORD(l)
Definition: pedump.c:82

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 340 of file CBandSiteMenu.cpp.

342 {
343  CComPtr<IPersist> pBand;
344  CLSID BandCLSID;
345  DWORD dwBandID;
346  UINT idMax;
347 
348  TRACE("CBandSiteMenu::QueryContextMenu(%p, %p, %u, %u, %u, 0x%x)\n", this, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
349 
350  /* First Merge the menu with the available bands */
351  idMax = Shell_MergeMenus(hmenu, m_hmenu, indexMenu, idCmdFirst, idCmdLast, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS);
352 
353  HMENU hmenuToolbars = GetSubMenu(hmenu, indexMenu);
354 
355  /* Enumerate all present bands and mark them as checked in the menu */
356  for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++)
357  {
358  if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand))))
359  continue;
360 
361  if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID)))
362  continue;
363 
364  UINT menuID;
365  if (IsEqualGUID(BandCLSID, CLSID_ISFBand))
366  {
367  menuID = _GetMenuIdFromISFBand(pBand);
368  if (menuID == UINT_MAX)
369  {
370  HRESULT hr;
371  hr = _AddISFBandToMenu(hmenuToolbars, 0, idCmdFirst, idCmdLast, pBand, dwBandID, &menuID);
372  if (SUCCEEDED(hr) && menuID > idMax)
373  idMax = menuID;
374  menuID -= idCmdFirst;
375  }
376  }
377  else
378  {
379  int i = m_ComCatGuids.Find(BandCLSID);
380  menuID = (i == -1 ? UINT_MAX : i + FIRST_COMCAT_MENU_ID);
381  }
382 
383  if (menuID != UINT_MAX)
384  CheckMenuItem(hmenuToolbars, menuID + idCmdFirst, MF_CHECKED);
385  }
386 
387  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(idMax - idCmdFirst +1));
388 }
HRESULT _AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown *pBand, DWORD dwBandID, UINT *newMenuId)
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:857
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
#define FIRST_COMCAT_MENU_ID
UINT uFlags
Definition: api.c:59
#define IID_PPV_ARG(Itype, ppType)
#define SEVERITY_SUCCESS
Definition: winerror.h:64
CSimpleArray< GUID > m_ComCatGuids
Definition: CBandSiteMenu.h:32
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
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define MF_CHECKED
Definition: winuser.h:132
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define UINT_MAX
Definition: limits.h:41
unsigned short USHORT
Definition: pedump.c:61
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define MM_SUBMENUSHAVEIDS
Definition: shlobj.h:2320
UINT _GetMenuIdFromISFBand(IUnknown *pBand)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define MM_DONTREMOVESEPS
Definition: shlobj.h:2321
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ SetOwner()

HRESULT STDMETHODCALLTYPE CBandSiteMenu::SetOwner ( IUnknown pOwner)
virtual

Implements IShellService.

Definition at line 330 of file CBandSiteMenu.cpp.

331 {
332  TRACE("CBandSiteMenu::SetOwner(%p, %p)\n", this, pOwner);
333 
334  /* Cache the menu that will be merged every time QueryContextMenu is called */
335  _CreateMenuPart();
336 
337  return pOwner->QueryInterface(IID_PPV_ARG(IBandSite, &m_BandSite));
338 }
CComPtr< IBandSite > m_BandSite
Definition: CBandSiteMenu.h:31
#define IID_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT _CreateMenuPart()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

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: