ReactOS 0.4.15-dev-6047-gb29e82d
CMenuSFToolbar Class Reference

#include <CMenuToolbars.h>

Inheritance diagram for CMenuSFToolbar:
Collaboration diagram for CMenuSFToolbar:

Public Member Functions

 CMenuSFToolbar (CMenuBand *menuBand)
 
virtual ~CMenuSFToolbar ()
 
HRESULT SetShellFolder (IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
 
HRESULT GetShellFolder (DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
 
virtual HRESULT FillToolbar (BOOL clearFirst=FALSE)
 
- Public Member Functions inherited from CMenuToolbarBase
 CMenuToolbarBase (CMenuBand *menuBand, BOOL usePager)
 
virtual ~CMenuToolbarBase ()
 
HRESULT IsWindowOwner (HWND hwnd)
 
HRESULT CreateToolbar (HWND hwndParent, DWORD dwFlags)
 
HRESULT GetWindow (HWND *phwnd)
 
HRESULT ShowDW (BOOL fShow)
 
HRESULT Close ()
 
HRESULT OnWinEvent (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 
HRESULT ChangeHotItem (CMenuToolbarBase *toolbar, INT item, DWORD dwFlags)
 
HRESULT ChangePopupItem (CMenuToolbarBase *toolbar, INT item)
 
HRESULT PopupSubMenu (UINT itemId, UINT index, IShellMenu *childShellMenu, BOOL keyInitiated)
 
HRESULT PopupSubMenu (UINT itemId, UINT index, HMENU menu)
 
HRESULT TrackContextMenu (IContextMenu *contextMenu, POINT pt)
 
HRESULT KeyboardItemChange (DWORD changeType)
 
HRESULT PrepareExecuteItem (INT iItem)
 
HRESULT ExecuteItem ()
 
HRESULT GetSizes (SIZE *pMinSize, SIZE *pMaxSize, SIZE *pIntegralSize)
 
HRESULT SetPosSize (int x, int y, int cx, int cy)
 
void InvalidateDraw ()
 
HRESULT DisableMouseTrack (BOOL bDisable)
 
virtual HRESULT FillToolbar (BOOL clearFirst=FALSE)=0
 
HRESULT CancelCurrentPopup ()
 
HRESULT PopupItem (INT iItem, BOOL keyInitiated)
 
HRESULT GetDataFromId (INT iItem, INT *pIndex, DWORD_PTR *pData)
 
HRESULT KillPopupTimer ()
 
HRESULT MenuBarMouseDown (INT iIndex, BOOL isLButton)
 
HRESULT MenuBarMouseUp (INT iIndex, BOOL isLButton)
 
HRESULT ProcessClick (INT iItem)
 
HRESULT ProcessContextMenu (INT iItem)
 
HRESULT BeforeCancelPopup ()
 

Protected Member Functions

virtual HRESULT OnDeletingButton (const NMTOOLBAR *tb)
 
virtual HRESULT InternalGetTooltip (INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax)
 
virtual HRESULT InternalExecuteItem (INT iItem, INT index, DWORD_PTR dwData)
 
virtual HRESULT InternalPopupItem (INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated)
 
virtual HRESULT InternalHasSubMenu (INT iItem, INT index, DWORD_PTR dwData)
 
virtual HRESULT InternalContextMenu (INT iItem, INT index, DWORD_PTR dwData, POINT pt)
 
- Protected Member Functions inherited from CMenuToolbarBase
virtual HRESULT OnDeletingButton (const NMTOOLBAR *tb)=0
 
virtual HRESULT InternalGetTooltip (INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax)=0
 
virtual HRESULT InternalExecuteItem (INT iItem, INT index, DWORD_PTR dwData)=0
 
virtual HRESULT InternalPopupItem (INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated)=0
 
virtual HRESULT InternalHasSubMenu (INT iItem, INT index, DWORD_PTR dwData)=0
 
virtual HRESULT InternalContextMenu (INT iItem, INT index, DWORD_PTR dwData, POINT pt)=0
 
HRESULT AddButton (DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
 
HRESULT AddSeparator (BOOL last)
 
HRESULT AddPlaceholder ()
 
HRESULT ClearToolbar ()
 
HWND GetToolbar ()
 

Private Attributes

CComPtr< IShellFolderm_shellFolder
 
LPCITEMIDLIST m_idList
 
HKEY m_hKey
 

Additional Inherited Members

- Protected Attributes inherited from CMenuToolbarBase
CMenuBandm_menuBand
 
DWORD m_dwMenuFlags
 
BOOL m_hasSizes
 
SIZE m_idealSize
 
SIZE m_itemSize
 
BOOL m_usePager
 
CMenuToolbarBasem_hotBar
 
INT m_hotItem
 
CMenuToolbarBasem_popupBar
 
INT m_popupItem
 
DWORD m_initFlags
 
BOOL m_isTrackingPopup
 
INT m_executeIndex
 
INT m_executeItem
 
DWORD_PTR m_executeData
 
BOOL m_cancelingPopup
 

Detailed Description

Definition at line 167 of file CMenuToolbars.h.

Constructor & Destructor Documentation

◆ CMenuSFToolbar()

CMenuSFToolbar::CMenuSFToolbar ( CMenuBand menuBand)

Definition at line 1300 of file CMenuToolbars.cpp.

1300 :
1301 CMenuToolbarBase(menuBand, TRUE),
1303 m_idList(NULL),
1304 m_hKey(NULL)
1305{
1306}
LPCITEMIDLIST m_idList
CComPtr< IShellFolder > m_shellFolder
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120

◆ ~CMenuSFToolbar()

CMenuSFToolbar::~CMenuSFToolbar ( )
virtual

Definition at line 1308 of file CMenuToolbars.cpp.

1309{
1310}

Member Function Documentation

◆ FillToolbar()

HRESULT CMenuSFToolbar::FillToolbar ( BOOL  clearFirst = FALSE)
virtual

Implements CMenuToolbarBase.

Definition at line 1326 of file CMenuToolbars.cpp.

1327{
1328 HRESULT hr;
1329
1330 CComPtr<IEnumIDList> eidl;
1331 hr = m_shellFolder->EnumObjects(GetToolbar(), SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &eidl);
1333 return hr;
1334
1335 HDPA dpaSort = DPA_Create(10);
1336
1338 hr = eidl->Next(1, &item, NULL);
1339 while (hr == S_OK)
1340 {
1341 if (m_menuBand->_CallCBWithItemPidl(item, 0x10000000, 0, 0) == S_FALSE)
1342 {
1343 DPA_AppendPtr(dpaSort, item);
1344 }
1345 else
1346 {
1348 }
1349
1350 hr = eidl->Next(1, &item, NULL);
1351 }
1352
1353 // If no items were added, show the "empty" placeholder
1354 if (DPA_GetPtrCount(dpaSort) == 0)
1355 {
1356 DPA_Destroy(dpaSort);
1357 return AddPlaceholder();
1358 }
1359
1360 TRACE("FillToolbar added %d items to the DPA\n", DPA_GetPtrCount(dpaSort));
1361
1363
1364 for (int i = 0; i<DPA_GetPtrCount(dpaSort);)
1365 {
1366 PWSTR MenuString;
1367
1368 INT index = 0;
1369 INT indexOpen = 0;
1370
1371 STRRET sr = { STRRET_CSTR, { 0 } };
1372
1373 item = (LPITEMIDLIST)DPA_GetPtr(dpaSort, i);
1374
1375 hr = m_shellFolder->GetDisplayNameOf(item, SIGDN_NORMALDISPLAY, &sr);
1377 {
1378 DPA_Destroy(dpaSort);
1379 return hr;
1380 }
1381
1382 StrRetToStr(&sr, NULL, &MenuString);
1383
1385
1386 LPCITEMIDLIST itemc = item;
1387
1388 SFGAOF attrs = SFGAO_FOLDER;
1389 hr = m_shellFolder->GetAttributesOf(1, &itemc, &attrs);
1390
1391 DWORD_PTR dwData = reinterpret_cast<DWORD_PTR>(item);
1392
1393 // Fetch next item already, so we know if the current one is the last
1394 i++;
1395
1396 AddButton(i, MenuString, attrs & SFGAO_FOLDER, index, dwData, i >= DPA_GetPtrCount(dpaSort));
1397
1398 CoTaskMemFree(MenuString);
1399 }
1400
1401 DPA_Destroy(dpaSort);
1402 return hr;
1403}
int CALLBACK PidlListSort(void *item1, void *item2, LPARAM lParam)
HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CMenuBand.cpp:773
HRESULT AddPlaceholder()
CMenuBand * m_menuBand
Definition: CMenuToolbars.h:39
HRESULT AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
BOOL WINAPI DPA_Sort(HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
Definition: dpa.c:813
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
GLuint index
Definition: glext.h:6031
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
int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder *sh, LPCITEMIDLIST pidl, int *pIndex)
Definition: iconcache.cpp:783
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define S_OK
Definition: intsafe.h:52
static HANDLE ULONG_PTR dwData
Definition: file.c:35
static ATOM item
Definition: dde.c:856
#define DPA_AppendPtr(hdpa, pitem)
Definition: commctrl.h:4958
#define DPA_GetPtrCount(hdpa)
Definition: commctrl.h:4955
#define DPA_GetPtr
Definition: commctrl.h:5
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
#define StrRetToStr
Definition: shlwapi.h:1751
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_CSTR
Definition: shtypes.idl:87
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define TRACE(s)
Definition: solgame.cpp:4
Definition: dpa.c:49
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
LONG_PTR LPARAM
Definition: windef.h:208
#define S_FALSE
Definition: winerror.h:2357

Referenced by CMenuBand::SetShellFolder(), and CMenuBand::SetSite().

◆ GetShellFolder()

HRESULT CMenuSFToolbar::GetShellFolder ( DWORD pdwFlags,
LPITEMIDLIST ppidl,
REFIID  riid,
void **  ppv 
)

Definition at line 1431 of file CMenuToolbars.cpp.

1432{
1433 HRESULT hr;
1434
1435 hr = m_shellFolder->QueryInterface(riid, ppv);
1437 return hr;
1438
1439 if (pdwFlags)
1440 *pdwFlags = m_dwMenuFlags;
1441
1442 if (ppidl)
1443 {
1444 LPITEMIDLIST pidl = NULL;
1445
1446 if (m_idList)
1447 {
1448 pidl = ILClone(m_idList);
1449 if (!pidl)
1450 {
1451 ERR("ILClone failed!\n");
1452 (*reinterpret_cast<IUnknown**>(ppv))->Release();
1453 return E_FAIL;
1454 }
1455 }
1456
1457 *ppidl = pidl;
1458 }
1459
1460 return hr;
1461}
#define ERR(fmt,...)
Definition: debug.h:110
#define E_FAIL
Definition: ddrawi.h:102
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

Referenced by CMenuBand::_CallCB(), and CMenuBand::GetShellFolder().

◆ InternalContextMenu()

HRESULT CMenuSFToolbar::InternalContextMenu ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
POINT  pt 
)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1463 of file CMenuToolbars.cpp.

1464{
1465 HRESULT hr;
1466 CComPtr<IContextMenu> contextMenu = NULL;
1467 LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(dwData);
1468
1469 hr = m_shellFolder->GetUIObjectOf(GetToolbar(), 1, &pidl, IID_NULL_PPV_ARG(IContextMenu, &contextMenu));
1471 {
1472 return hr;
1473 }
1474
1475 hr = TrackContextMenu(contextMenu, pt);
1476
1477 return hr;
1478}
HRESULT TrackContextMenu(IContextMenu *contextMenu, POINT pt)
#define pt(x, y)
Definition: drawing.c:79
#define IID_NULL_PPV_ARG(Itype, ppType)

◆ InternalExecuteItem()

HRESULT CMenuSFToolbar::InternalExecuteItem ( INT  iItem,
INT  index,
DWORD_PTR  dwData 
)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1480 of file CMenuToolbars.cpp.

1481{
1482 return m_menuBand->_CallCBWithItemPidl(reinterpret_cast<LPITEMIDLIST>(data), SMC_SFEXEC, 0, 0);
1483}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ InternalGetTooltip()

HRESULT CMenuSFToolbar::InternalGetTooltip ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
LPWSTR  pszText,
INT  cchTextMax 
)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1405 of file CMenuToolbars.cpp.

1406{
1407 //ITEMIDLIST * pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1409 return E_NOTIMPL;
1410}
#define UNIMPLEMENTED
Definition: debug.h:115
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ InternalHasSubMenu()

HRESULT CMenuSFToolbar::InternalHasSubMenu ( INT  iItem,
INT  index,
DWORD_PTR  dwData 
)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1522 of file CMenuToolbars.cpp.

1523{
1524 HRESULT hr;
1525 LPCITEMIDLIST pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1526
1527 SFGAOF attrs = SFGAO_FOLDER;
1528 hr = m_shellFolder->GetAttributesOf(1, &pidl, &attrs);
1530 return hr;
1531
1532 return (attrs & SFGAO_FOLDER) ? S_OK : S_FALSE;
1533}

◆ InternalPopupItem()

HRESULT CMenuSFToolbar::InternalPopupItem ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
BOOL  keyInitiated 
)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1485 of file CMenuToolbars.cpp.

1486{
1487 HRESULT hr;
1488 UINT uId;
1489 UINT uIdAncestor;
1490 DWORD flags;
1491 CComPtr<IShellMenuCallback> psmc;
1492 CComPtr<IShellMenu> shellMenu;
1493
1494 LPITEMIDLIST pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1495
1496 if (!pidl)
1497 return E_FAIL;
1498
1501 return hr;
1502
1503 m_menuBand->GetMenuInfo(&psmc, &uId, &uIdAncestor, &flags);
1504
1505 // FIXME: not sure what to use as uId/uIdAncestor here
1506 hr = shellMenu->Initialize(psmc, 0, uId, SMINIT_VERTICAL);
1508 return hr;
1509
1510 CComPtr<IShellFolder> childFolder;
1511 hr = m_shellFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &childFolder));
1513 return hr;
1514
1515 hr = shellMenu->SetShellFolder(childFolder, NULL, NULL, SMSET_TOP);
1517 return hr;
1518
1519 return PopupSubMenu(iItem, index, shellMenu, keyInitiated);
1520}
virtual HRESULT STDMETHODCALLTYPE GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags)
Definition: CMenuBand.cpp:91
HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu *childShellMenu, BOOL keyInitiated)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
unsigned int UINT
Definition: ndis.h:50
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
#define IID_PPV_ARG(Itype, ppType)

◆ OnDeletingButton()

HRESULT CMenuSFToolbar::OnDeletingButton ( const NMTOOLBAR tb)
protectedvirtual

Implements CMenuToolbarBase.

Definition at line 1412 of file CMenuToolbars.cpp.

1413{
1414 ILFree(reinterpret_cast<LPITEMIDLIST>(tb->tbButton.dwData));
1415 return S_OK;
1416}
static const WCHAR tb[]
Definition: suminfo.c:285
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:929

◆ SetShellFolder()

HRESULT CMenuSFToolbar::SetShellFolder ( IShellFolder psf,
LPCITEMIDLIST  pidlFolder,
HKEY  hKey,
DWORD  dwFlags 
)

Definition at line 1418 of file CMenuToolbars.cpp.

1419{
1420 m_shellFolder = psf;
1421 m_idList = ILClone(pidlFolder);
1422 m_hKey = hKey;
1424
1425 if (IsWindow())
1426 ClearToolbar();
1427
1428 return S_OK;
1429}
FxAutoRegKey hKey
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
BOOL WINAPI IsWindow(_In_opt_ HWND)

Referenced by CMenuBand::SetShellFolder().

Member Data Documentation

◆ m_hKey

HKEY CMenuSFToolbar::m_hKey
private

Definition at line 173 of file CMenuToolbars.h.

Referenced by SetShellFolder().

◆ m_idList

LPCITEMIDLIST CMenuSFToolbar::m_idList
private

Definition at line 172 of file CMenuToolbars.h.

Referenced by GetShellFolder(), and SetShellFolder().

◆ m_shellFolder

CComPtr<IShellFolder> CMenuSFToolbar::m_shellFolder
private

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