Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.9 KiB

  1. #ifndef CToolbarMenu_H
  2. #define CToolbarMenu_H
  3. #include "menuband.h"
  4. #include "mnbase.h"
  5. #include "cwndproc.h"
  6. #define TF_TBMENU 0
  7. class CToolbarMenu : public CMenuToolbarBase,
  8. public CNotifySubclassWndProc
  9. {
  10. public:
  11. // *** IUnknown (override) ***
  12. virtual STDMETHODIMP_(ULONG) AddRef(void) { return CMenuToolbarBase::AddRef(); };
  13. virtual STDMETHODIMP_(ULONG) Release(void) { return CMenuToolbarBase::Release(); };
  14. virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj) { return CMenuToolbarBase::QueryInterface(riid, ppvObj); };
  15. // *** IWinEventHandler methods (override) ***
  16. virtual STDMETHODIMP IsWindowOwner(HWND hwnd);
  17. virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  18. virtual BOOL v_TrackingSubContextMenu() { return _fTrackingSubMenu; };
  19. virtual void v_Show(BOOL fShow, BOOL fForceUpdate) ;
  20. virtual BOOL v_UpdateIconSize(UINT uIconSize, BOOL fUpdateButtons) { return FALSE; };
  21. virtual void v_UpdateButtons(BOOL fNegotiateSize) ;
  22. virtual HRESULT v_GetSubMenu(int iCmd, const GUID* pguidService, REFIID riid, void** pObj) {return E_FAIL;};
  23. virtual HRESULT v_CallCBItem(int idtCmd, UINT dwMsg, WPARAM wParam, LPARAM lParam) ;
  24. virtual HRESULT v_GetState(int idtCmd, LPSMDATA psmd);
  25. virtual HRESULT v_ExecItem(int iCmd);
  26. virtual DWORD v_GetFlags(int iCmd) { return 0; };
  27. virtual void v_Close(); // override
  28. virtual int v_GetDragOverButton() { ASSERT(0); return 0;};
  29. virtual HRESULT v_GetInfoTip(int iCmd, LPTSTR psz, UINT cch) {return E_NOTIMPL;};
  30. virtual HRESULT v_CreateTrackPopup(int idCmd, REFIID riid, void** ppvObj) {ASSERT(0); return E_NOTIMPL;};
  31. virtual void v_Refresh() {/*ASSERT(0);*/};
  32. virtual void v_SendMenuNotification(UINT idCmd, BOOL fClear) {};
  33. CToolbarMenu(DWORD dwFlags, HWND hwndTB);
  34. protected:
  35. virtual STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) { return E_NOTIMPL; }
  36. virtual LRESULT _DefWindowProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  37. virtual void CreateToolbar(HWND hwndParent);
  38. virtual void GetSize(SIZE* psize);
  39. void _CancelMenu();
  40. void _FillToolbar();
  41. HWND _hwndSubject;
  42. BITBOOL _fTrackingSubMenu:1;
  43. friend CMenuToolbarBase* ToolbarMenu_Create(HWND hwnd);
  44. };
  45. class CTrackShellMenu : public ITrackShellMenu,
  46. public IShellMenu2,
  47. public IObjectWithSite,
  48. public IServiceProvider
  49. {
  50. public:
  51. // *** IUnknown ***
  52. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  53. virtual STDMETHODIMP_(ULONG) AddRef(void);
  54. virtual STDMETHODIMP_(ULONG) Release(void);
  55. // *** IShellMenu methods ***
  56. virtual STDMETHODIMP Initialize(IShellMenuCallback* psmc, UINT uId, UINT uIdAncestor, DWORD dwFlags);
  57. virtual STDMETHODIMP GetMenuInfo(IShellMenuCallback** ppsmc, UINT* puId,
  58. UINT* puIdAncestor, DWORD* pdwFlags);
  59. virtual STDMETHODIMP SetShellFolder(IShellFolder* psf, LPCITEMIDLIST pidlFolder, HKEY hkey, DWORD dwFlags);
  60. virtual STDMETHODIMP GetShellFolder(DWORD* pdwFlags, LPITEMIDLIST* ppidl, REFIID riid, void** ppvObj);
  61. virtual STDMETHODIMP SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
  62. virtual STDMETHODIMP GetMenu(HMENU* phmenu, HWND* phwnd, DWORD* pdwFlags);
  63. virtual STDMETHODIMP InvalidateItem(LPSMDATA psmd, DWORD dwFlags);
  64. virtual STDMETHODIMP GetState(LPSMDATA psmd);
  65. virtual STDMETHODIMP SetMenuToolbar(IUnknown* punk, DWORD dwFlags);
  66. // *** ITrackShellMenu methods ***
  67. virtual STDMETHODIMP SetObscured(HWND hwndTB, IUnknown* punkBand, DWORD dwSMSetFlags);
  68. virtual STDMETHODIMP Popup(HWND hwnd, POINTL *ppt, RECTL *prcExclude, DWORD dwFlags);
  69. // *** IObjectWithSite methods ***
  70. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  71. virtual STDMETHODIMP GetSite(REFIID ridd, void** ppvObj) { *ppvObj = NULL; return E_NOTIMPL; };
  72. // *** IServiceProvider methods ***
  73. virtual STDMETHODIMP QueryService(REFGUID guidService,
  74. REFIID riid, void **ppvObj);
  75. // *** IShellMenu2 methods ***
  76. virtual STDMETHODIMP GetSubMenu(UINT idCmd, REFIID riid, void **ppvObj);
  77. virtual STDMETHODIMP SetToolbar(HWND hwnd, DWORD dwFlags);
  78. virtual STDMETHODIMP SetMinWidth(int cxMenu);
  79. virtual STDMETHODIMP SetNoBorder(BOOL fNoBorder);
  80. virtual STDMETHODIMP SetTheme(LPCWSTR pszTheme);
  81. CTrackShellMenu();
  82. private:
  83. virtual ~CTrackShellMenu();
  84. IShellMenu* _psmClient;
  85. IShellMenu* _psm;
  86. IShellMenu2* _psm2;
  87. IUnknown* _punkSite;
  88. int _cRef;
  89. HMENU _hmenu;
  90. BITBOOL _fDestroyTopLevel : 1;
  91. };
  92. HRESULT ToolbarMenu_Popup(HWND hwnd, LPRECT prc, IUnknown* punk, HWND hwndTB, int idMenu, DWORD dwFlags);
  93. CMenuToolbarBase* ToolbarMenu_Create(HWND hwnd);
  94. #endif