ReactOS  0.4.14-dev-1115-gebeeb9d
CMenuSite.h
Go to the documentation of this file.
1 /*
2  * Shell Menu Site
3  *
4  * Copyright 2014 David Quintana
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 #pragma once
21 
22 class CMenuSite :
23  public CComCoClass<CMenuSite, &CLSID_MenuBandSite>,
24  public CComObjectRootEx<CComMultiThreadModelNoCS>,
25  public CWindowImpl<CMenuSite, CWindow, CControlWinTraits>,
26  public IBandSite,
27  public IDeskBarClient,
28  public IOleCommandTarget,
29  public IInputObject,
30  public IInputObjectSite,
31  public IWinEventHandler,
32  public IServiceProvider
33 {
34 private:
35  CComPtr<IUnknown> m_DeskBarSite;
36  CComPtr<IUnknown> m_BandObject;
37  CComPtr<IDeskBand> m_DeskBand;
38  CComPtr<IWinEventHandler> m_WinEventHandler;
40 
41 public:
42  CMenuSite();
43  virtual ~CMenuSite() {}
44 
45  DECLARE_WND_CLASS_EX(_T("MenuSite"), 0, COLOR_MENU)
46 
51  COM_INTERFACE_ENTRY_IID(IID_IBandSite, IBandSite)
52  COM_INTERFACE_ENTRY_IID(IID_IDeskBarClient, IDeskBarClient)
54  COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
55  COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
56  COM_INTERFACE_ENTRY_IID(IID_IInputObjectSite, IInputObjectSite)
57  COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
58  COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
59  END_COM_MAP()
60 
61  // IBandSite
62  virtual HRESULT STDMETHODCALLTYPE AddBand(IUnknown * punk);
63  virtual HRESULT STDMETHODCALLTYPE EnumBands(UINT uBand, DWORD* pdwBandID);
64  virtual HRESULT STDMETHODCALLTYPE QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName);
66 
67  // IDeskBarClient
69  virtual HRESULT STDMETHODCALLTYPE GetSize(DWORD dwWhich, LPRECT prc);
71 
72  // IOleWindow
73  virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd);
74 
75  // IOleCommandTarget
76  virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText);
77  virtual HRESULT STDMETHODCALLTYPE Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
78 
79  // IInputObject
80  virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg);
83 
84  // IInputObjectSite
85  virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(IUnknown *punkObj, BOOL fSetFocus);
86 
87  // IWinEventHandler
90 
91  // IServiceProvider
92  virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
93 
94 
95  // Using custom message map instead
96  virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD mapId = 0);
97 
98  // UNIMPLEMENTED
101  virtual HRESULT STDMETHODCALLTYPE RemoveBand(DWORD dwBandID);
103  virtual HRESULT STDMETHODCALLTYPE SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState);
104  virtual HRESULT STDMETHODCALLTYPE SetModeDBC(DWORD dwMode);
105 
106 private:
107  IUnknown * ToIUnknown() { return static_cast<IDeskBarClient*>(this); }
108 };
virtual HRESULT STDMETHODCALLTYPE GetBandObject(DWORD dwBandID, REFIID riid, VOID **ppv)
Definition: CMenuSite.cpp:96
#define REFIID
Definition: guiddef.h:118
virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
Definition: CMenuSite.cpp:178
Definition: scsiwmi.h:51
virtual HRESULT STDMETHODCALLTYPE HasFocusIO()
Definition: CMenuSite.cpp:348
virtual ~CMenuSite()
Definition: CMenuSite.h:43
REFIID riid
Definition: precomp.h:44
struct IOleCommandTarget::_tagOLECMD OLECMD
CComPtr< IUnknown > m_BandObject
Definition: CMenuSite.h:36
CComPtr< IWinEventHandler > m_WinEventHandler
Definition: CMenuSite.h:38
virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
Definition: CMenuSite.cpp:204
#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd)
Definition: atlwin.h:1876
HWND hWnd
Definition: settings.c:17
REFIID LPVOID * ppv
Definition: atlbase.h:39
virtual HRESULT STDMETHODCALLTYPE SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState)
Definition: CMenuSite.cpp:333
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:611
UINT_PTR WPARAM
Definition: windef.h:207
WPARAM wParam
Definition: combotst.c:138
virtual HRESULT STDMETHODCALLTYPE AddBand(IUnknown *punk)
Definition: CMenuSite.cpp:36
virtual HRESULT STDMETHODCALLTYPE UIActivateDBC(DWORD dwState)
Definition: CMenuSite.cpp:256
virtual HRESULT STDMETHODCALLTYPE IsWindowOwner(HWND hWnd)
Definition: CMenuSite.cpp:159
struct IOleCommandTarget::_tagOLECMDTEXT OLECMDTEXT
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2723
virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd)
Definition: CMenuSite.cpp:149
HWND m_hWndBand
Definition: CMenuSite.h:39
unsigned int BOOL
Definition: ntddk_ex.h:94
CComPtr< IUnknown > m_DeskBarSite
Definition: CMenuSite.h:35
virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(IUnknown *punkObj, BOOL fSetFocus)
Definition: CMenuSite.cpp:353
#define COLOR_MENU
Definition: winuser.h:907
LONG_PTR LPARAM
Definition: windef.h:208
virtual HRESULT STDMETHODCALLTYPE QueryBand(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName)
Definition: CMenuSite.cpp:107
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
#define _T(x)
Definition: vfdio.h:22
virtual HRESULT STDMETHODCALLTYPE GetBandSiteInfo(BANDSITEINFO *pbsinfo)
Definition: CMenuSite.cpp:318
LONG HRESULT
Definition: typedefs.h:78
virtual HRESULT STDMETHODCALLTYPE SetModeDBC(DWORD dwMode)
Definition: CMenuSite.cpp:338
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
unsigned long DWORD
Definition: ntddk_ex.h:95
virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg)
Definition: CMenuSite.cpp:264
virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
Definition: CMenuSite.cpp:198
virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg)
Definition: CMenuSite.cpp:343
CComPtr< IDeskBand > m_DeskBand
Definition: CMenuSite.h:37
REFIID LPVOID * ppvObject
Definition: precomp.h:44
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode)
Definition: CMenuSite.cpp:313
virtual HRESULT STDMETHODCALLTYPE GetSize(DWORD dwWhich, LPRECT prc)
Definition: CMenuSite.cpp:128
#define DECLARE_REGISTRY_RESOURCEID(x)
Definition: atlcom.h:605
IUnknown * ToIUnknown()
Definition: CMenuSite.h:107
virtual HRESULT STDMETHODCALLTYPE OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
Definition: CMenuSite.cpp:170
virtual HRESULT STDMETHODCALLTYPE SetBandSiteInfo(const BANDSITEINFO *pbsinfo)
Definition: CMenuSite.cpp:328
virtual HRESULT STDMETHODCALLTYPE EnumBands(UINT uBand, DWORD *pdwBandID)
Definition: CMenuSite.cpp:86
virtual HRESULT STDMETHODCALLTYPE RemoveBand(DWORD dwBandID)
Definition: CMenuSite.cpp:323
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD mapId=0)
Definition: CMenuSite.cpp:272
unsigned int UINT
Definition: ndis.h:50
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:639
const GUID IID_IOleWindow
unsigned int ULONG
Definition: retypes.h:1
#define const
Definition: zconf.h:230
#define IDR_MENUBANDSITE
Definition: shresdef.h:807
#define END_COM_MAP()
Definition: atlcom.h:552
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
_Out_ LPRECT prc
Definition: ntgdi.h:1658
virtual HRESULT STDMETHODCALLTYPE SetDeskBarSite(IUnknown *punkSite)
Definition: CMenuSite.cpp:210
LPARAM lParam
Definition: combotst.c:139