ReactOS  0.4.13-dev-257-gfabbd7c
CMenuCallback Class Reference

#include <internettoolbar.h>

Inheritance diagram for CMenuCallback:
Collaboration diagram for CMenuCallback:

Public Member Functions

 CMenuCallback ()
 
virtual ~CMenuCallback ()
 
HRESULT STDMETHODCALLTYPE GetObject (LPSMDATA psmd, REFIID riid, void **ppvObject)
 
virtual HRESULT STDMETHODCALLTYPE CallbackSM (LPSMDATA psmd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 CMenuCallback (struct _test_info *testResults, int testsCount)
 
void SetTest (int i)
 
HRESULT STDMETHODCALLTYPE CallbackSM (LPSMDATA psmd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- Public Member Functions inherited from CUnknownBase< IShellMenuCallback >
 CUnknownBase (bool autoDelete=true, LONG initialRef=0)
 
ULONG STDMETHODCALLTYPE AddRef ()
 
ULONG STDMETHODCALLTYPE Release ()
 
HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppv)
 
virtual ~CUnknownBase ()
 
LONG GetRef () const
 
- 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 ()
 

Protected Member Functions

const QITABGetQITab ()
 

Protected Attributes

int m_iTest
 
int m_iCallback
 
struct _test_infom_results
 
int m_testsCount
 

Private Attributes

CComPtr< IShellMenufFavoritesMenu
 

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 40 of file internettoolbar.h.

Constructor & Destructor Documentation

◆ CMenuCallback() [1/2]

CMenuCallback::CMenuCallback ( )

Definition at line 364 of file internettoolbar.cpp.

365 {
366 }

◆ ~CMenuCallback()

CMenuCallback::~CMenuCallback ( )
virtual

Definition at line 368 of file internettoolbar.cpp.

369 {
370 }

◆ CMenuCallback() [2/2]

CMenuCallback::CMenuCallback ( struct _test_info testResults,
int  testsCount 
)
inline

Definition at line 230 of file menu.cpp.

231  :CUnknownBase( true, 0 )
232  {
233  m_iTest = 0;
234  m_iCallback = 0;
235  m_results = testResults;
236  m_testsCount = testsCount;
237  }
int m_iTest
Definition: menu.cpp:218
CUnknownBase(bool autoDelete=true, LONG initialRef=0)
Definition: unknownbase.h:13
int m_iCallback
Definition: menu.cpp:219
struct _test_info * m_results
Definition: menu.cpp:220
int m_testsCount
Definition: menu.cpp:221

Member Function Documentation

◆ CallbackSM() [1/2]

HRESULT STDMETHODCALLTYPE CMenuCallback::CallbackSM ( LPSMDATA  psmd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Implements IShellMenuCallback.

Definition at line 529 of file internettoolbar.cpp.

530 {
531  switch (uMsg)
532  {
533  case SMC_INITMENU:
534  break;
535  case SMC_CREATE:
536  break;
537  case SMC_EXITMENU:
538  break;
539  case SMC_GETINFO:
540  {
541  SMINFO *infoPtr = reinterpret_cast<SMINFO *>(lParam);
542  if ((infoPtr->dwMask & SMIM_FLAGS) != 0)
543  {
544  if (psmd->uId == FCIDM_MENU_FAVORITES)
545  {
546  infoPtr->dwFlags |= SMIF_DROPCASCADE;
547  }
548  else
549  {
550  infoPtr->dwFlags |= SMIF_TRACKPOPUP;
551  }
552  }
553  if ((infoPtr->dwMask & SMIM_ICON) != 0)
554  infoPtr->iIcon = -1;
555  return S_OK;
556  }
557  case SMC_GETSFINFO:
558  break;
559  case SMC_GETOBJECT:
560  return GetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
561  case SMC_GETSFOBJECT:
562  break;
563  case SMC_EXEC:
564  PostMessageW(psmd->hwnd, WM_COMMAND, psmd->uId, 0);
565  break;
566  case SMC_SFEXEC:
567  SHInvokeDefaultCommand(psmd->hwnd, psmd->psf, psmd->pidlItem);
568  break;
569  case SMC_SFSELECTITEM:
570  break;
571  case 13:
572  // return tooltip
573  break;
574  case SMC_REFRESH:
575  break;
576  case SMC_DEMOTE:
577  break;
578  case SMC_PROMOTE:
579  break;
580  case 0x13:
581  break;
582  case SMC_DEFAULTICON:
583  break;
584  case SMC_NEWITEM:
585  break;
586  case SMC_CHEVRONEXPAND:
587  break;
588  case SMC_DISPLAYCHEVRONTIP:
589  break;
590  case SMC_SETSFOBJECT:
591  break;
592  case SMC_SHCHANGENOTIFY:
593  break;
594  case SMC_CHEVRONGETTIP:
595  break;
596  case SMC_SFDDRESTRICTED:
597  break;
598  case 0x35:
599  break;
600  case 49:
601  break;
602  case 0x10000000:
603  break;
604  }
605  return S_FALSE;
606 }
LPITEMIDLIST pidlItem
Definition: shobjidl.idl:2624
HRESULT WINAPI SHInvokeDefaultCommand(HWND hWnd, IShellFolder *lpFolder, LPCITEMIDLIST lpApidl)
Definition: ordinal.c:2928
WPARAM wParam
Definition: combotst.c:138
HRESULT STDMETHODCALLTYPE GetObject(LPSMDATA psmd, REFIID riid, void **ppvObject)
#define S_FALSE
Definition: winerror.h:2357
#define SMC_EXEC
Definition: undocshell.h:611
IShellFolder * psf
Definition: shobjidl.idl:2625
#define WM_COMMAND
Definition: winuser.h:1716
#define S_OK
Definition: intsafe.h:59
#define FCIDM_MENU_FAVORITES
Definition: shlobj.h:557
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SMDM_TOOLBAR struct tagSMINFO SMINFO
LPARAM lParam
Definition: combotst.c:139

◆ CallbackSM() [2/2]

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

Implements IShellMenuCallback.

Definition at line 244 of file menu.cpp.

245  {
246  /*trace ("callback type %d\n", uMsg);*/
247 
248  /*
249  * it seems callback 0x10000000 is called for every item added so
250  * we will ignore consecutive callbacks of this type
251  * Note: this callback is invoked by shell32.dll!CMenuSFToolbar::_FilterPidl
252  */
253  if (uMsg == 0x10000000 && m_results[m_iCallback-1].uMsg == 0x10000000)
254  {
255  return S_OK;
256  }
257 
258  m_iCallback++;
260  {
261  ok(0, "Got more callbacks than expected! (%d not %d). uMsg: %d\n", m_iCallback, m_testsCount, uMsg);
262  return S_OK;
263  }
264 
265  struct _test_info *result = &m_results[m_iCallback-1];
266 
267  ok(psmd != NULL, "Got NULL psmd\n");
268  ok(m_iTest == result->iTest, "Wrong test number (%d not %d)\n", m_iTest, result->iTest);
269  ok(result->uMsg == uMsg, "%d: Got wrong uMsg (%d instead of %d)\n", m_iCallback, uMsg, result->uMsg);
270 
271  if(uMsg == SMC_CREATE)
272  {
273  ok(psmd->dwFlags == 0, "wrong dwFlags\n");
274  ok(psmd->dwMask == 0, "wrong dwMask\n");
275  ok(psmd->hmenu == 0, "wrong hmenu\n");
276  ok(psmd->hwnd == 0, "wrong hwnd\n");
277  ok(psmd->punk != NULL, "punk is null\n");
278  }
279 
280  if (uMsg == SMC_GETSFOBJECT)
281  {
282  ok(psmd->psf != 0, "wrong dwFlags\n");
283  }
284 
285  return S_FALSE;
286  }
UINT uMsg
Definition: menu.cpp:213
IUnknown * punk
Definition: shobjidl.idl:2622
int m_iTest
Definition: menu.cpp:218
DWORD dwMask
Definition: shobjidl.idl:2615
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
IShellFolder * psf
Definition: shobjidl.idl:2625
int m_iCallback
Definition: menu.cpp:219
struct _test_info * m_results
Definition: menu.cpp:220
DWORD dwFlags
Definition: shobjidl.idl:2616
#define S_OK
Definition: intsafe.h:59
GLuint64EXT * result
Definition: glext.h:11304
HMENU hmenu
Definition: shobjidl.idl:2617
int m_testsCount
Definition: menu.cpp:221

◆ GetObject()

HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject ( LPSMDATA  psmd,
REFIID  riid,
void **  ppvObject 
)

Definition at line 465 of file internettoolbar.cpp.

466 {
467  CComPtr<IShellMenu> parentMenu;
468  CComPtr<IShellMenu> newMenu;
469  CComPtr<IShellFolder> favoritesFolder;
470  LPITEMIDLIST favoritesPIDL;
471  HWND ownerWindow;
472  HMENU parentHMenu;
473  HMENU favoritesHMenu;
474  HKEY orderRegKey;
475  DWORD disposition;
476  HRESULT hResult;
477  static const TCHAR szFavoritesKey[] =
478  _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MenuOrder\\Favorites");
479 
480  if (!IsEqualIID(riid, IID_IShellMenu))
481  return E_FAIL;
482  if (psmd->uId != FCIDM_MENU_FAVORITES)
483  return E_FAIL;
484 
485  // create favorites menu
486  hResult = psmd->punk->QueryInterface(IID_PPV_ARG(IShellMenu, &parentMenu));
487  if (FAILED_UNEXPECTEDLY(hResult))
488  return hResult;
489  hResult = parentMenu->GetMenu(&parentHMenu, &ownerWindow, NULL);
490  if (FAILED_UNEXPECTEDLY(hResult))
491  return hResult;
492  favoritesHMenu = GetSubMenu(parentHMenu, 3);
493  if (favoritesHMenu == NULL)
494  return E_FAIL;
495 
496  if (fFavoritesMenu.p == NULL)
497  {
498  hResult = CMenuBand_CreateInstance(IID_PPV_ARG(IShellMenu, &newMenu));
499  if (FAILED_UNEXPECTEDLY(hResult))
500  return hResult;
501  hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED);
502  if (FAILED_UNEXPECTEDLY(hResult))
503  return hResult;
504 
505  RegCreateKeyEx(HKEY_CURRENT_USER, szFavoritesKey,
506  0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &orderRegKey, &disposition);
507 
508  hResult = GetFavoritesFolder(&favoritesFolder, &favoritesPIDL);
509  if (FAILED_UNEXPECTEDLY(hResult))
510  return hResult;
511 
512  hResult = newMenu->SetShellFolder(favoritesFolder, favoritesPIDL, orderRegKey, SMSET_BOTTOM | SMINIT_CACHED | SMINV_ID);
513  if (favoritesPIDL)
514  ILFree(favoritesPIDL);
515 
516  if (FAILED(hResult))
517  return hResult;
518 
519  fFavoritesMenu = newMenu;
520  }
521 
522  hResult = fFavoritesMenu->SetMenu(favoritesHMenu, ownerWindow, SMSET_TOP | SMSET_DONTOWN);
523  if (FAILED_UNEXPECTEDLY(hResult))
524  return hResult;
525 
526  return fFavoritesMenu->QueryInterface(riid, ppvObject);
527 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define KEY_READ
Definition: nt_native.h:1023
REFIID riid
Definition: precomp.h:44
#define HKEY_CURRENT_USER
Definition: winreg.h:11
IUnknown * punk
Definition: shobjidl.idl:2622
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
static HRESULT GetFavoritesFolder(IShellFolder **ppsfFavorites, LPITEMIDLIST *ppidl)
#define KEY_WRITE
Definition: nt_native.h:1031
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID * ppvObject
Definition: precomp.h:44
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
CComPtr< IShellMenu > fFavoritesMenu
#define FCIDM_MENU_FAVORITES
Definition: shlobj.h:557
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define RegCreateKeyEx
Definition: winreg.h:501
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

Referenced by CallbackSM().

◆ GetQITab()

const QITAB* CMenuCallback::GetQITab ( )
inlineprotectedvirtual

Implements CUnknownBase< IShellMenuCallback >.

Definition at line 223 of file menu.cpp.

224  {
225  static const QITAB tab[] = {{ &IID_IShellMenuCallback, OFFSETOFCLASS(IShellMenuCallback, CMenuCallback) }, {0}};
226  return tab;
227  }
#define OFFSETOFCLASS(base, derived)
Definition: shlwapi.h:2086

◆ SetTest()

void CMenuCallback::SetTest ( int  i)
inline

Definition at line 239 of file menu.cpp.

240  {
241  m_iTest = i;
242  }
int m_iTest
Definition: menu.cpp:218
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

Member Data Documentation

◆ fFavoritesMenu

CComPtr<IShellMenu> CMenuCallback::fFavoritesMenu
private

Definition at line 45 of file internettoolbar.h.

Referenced by GetObject().

◆ m_iCallback

int CMenuCallback::m_iCallback
protected

Definition at line 219 of file menu.cpp.

Referenced by CallbackSM(), and CMenuCallback().

◆ m_iTest

int CMenuCallback::m_iTest
protected

Definition at line 218 of file menu.cpp.

Referenced by CallbackSM(), CMenuCallback(), and SetTest().

◆ m_results

struct _test_info* CMenuCallback::m_results
protected

Definition at line 220 of file menu.cpp.

Referenced by CallbackSM(), and CMenuCallback().

◆ m_testsCount

int CMenuCallback::m_testsCount
protected

Definition at line 221 of file menu.cpp.

Referenced by CallbackSM(), and CMenuCallback().


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