1 /* 2 * Shell Menu Desk Bar 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 typedef CWinTraits< 23 WS_POPUP | WS_DLGFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 24 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_PALETTEWINDOW 25 > CMenuWinTraits; 26 27 class CMenuDeskBar : 28 public CComCoClass<CMenuDeskBar, &CLSID_MenuDeskBar>, 29 public CComObjectRootEx<CComMultiThreadModelNoCS>, 30 public CWindowImpl<CMenuDeskBar, CWindow, CMenuWinTraits>, 31 public IOleCommandTarget, 32 public IServiceProvider, 33 public IInputObjectSite, 34 public IInputObject, 35 public IMenuPopup, 36 public IObjectWithSite, 37 public IBanneredBar, 38 public IInitializeObject 39 { 40 private: 41 CComPtr<IUnknown> m_Site; 42 CComPtr<IUnknown> m_Client; 43 CComPtr<IMenuPopup> m_SubMenuParent; 44 CComPtr<IMenuPopup> m_SubMenuChild; 45 46 HWND m_ClientWindow; 47 48 DWORD m_IconSize; 49 HBITMAP m_Banner; 50 51 BOOL m_Shown; 52 DWORD m_ShowFlags; 53 54 BOOL m_didAddRef; 55 56 virtual void OnFinalMessage(HWND hWnd); 57 public: 58 CMenuDeskBar(); 59 virtual ~CMenuDeskBar(); 60 61 DECLARE_REGISTRY_RESOURCEID(IDR_MENUDESKBAR) 62 DECLARE_NOT_AGGREGATABLE(CMenuDeskBar) 63 DECLARE_PROTECT_FINAL_CONSTRUCT() 64 65 DECLARE_WND_CLASS_EX(_T("BaseBar"), CS_SAVEBITS | CS_DROPSHADOW, COLOR_3DFACE) 66 67 BEGIN_MSG_MAP(CMenuDeskBar) 68 MESSAGE_HANDLER(WM_CREATE, _OnCreate) 69 MESSAGE_HANDLER(WM_SIZE, _OnSize) 70 MESSAGE_HANDLER(WM_NOTIFY, _OnNotify) 71 MESSAGE_HANDLER(WM_PAINT, _OnPaint) 72 MESSAGE_HANDLER(WM_ACTIVATE, _OnActivate) 73 MESSAGE_HANDLER(WM_ACTIVATEAPP, _OnAppActivate) 74 MESSAGE_HANDLER(WM_MOUSEACTIVATE, _OnMouseActivate) 75 MESSAGE_HANDLER(WM_WININICHANGE , _OnWinIniChange) 76 MESSAGE_HANDLER(WM_NCPAINT, _OnNcPaint) 77 MESSAGE_HANDLER(WM_CLOSE, _OnClose) 78 END_MSG_MAP() 79 80 BEGIN_COM_MAP(CMenuDeskBar) 81 COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup) 82 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) 83 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider) 84 COM_INTERFACE_ENTRY_IID(IID_IInputObjectSite, IInputObjectSite) 85 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject) 86 COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IMenuPopup) 87 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IMenuPopup) 88 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 89 COM_INTERFACE_ENTRY_IID(IID_IBanneredBar, IBanneredBar) 90 COM_INTERFACE_ENTRY_IID(IID_IInitializeObject, IInitializeObject) 91 END_COM_MAP() 92 93 // *** IMenuPopup methods *** 94 virtual HRESULT STDMETHODCALLTYPE Popup(POINTL *ppt, RECTL *prcExclude, MP_POPUPFLAGS dwFlags); 95 virtual HRESULT STDMETHODCALLTYPE OnSelect(DWORD dwSelectType); 96 virtual HRESULT STDMETHODCALLTYPE SetSubMenu(IMenuPopup *pmp, BOOL fSet); 97 98 // *** IOleWindow methods *** 99 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *phwnd); 100 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); 101 102 // *** IObjectWithSite methods *** 103 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite); 104 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, PVOID *ppvSite); 105 106 // *** IBanneredBar methods *** 107 virtual HRESULT STDMETHODCALLTYPE SetIconSize(DWORD iIcon); 108 virtual HRESULT STDMETHODCALLTYPE GetIconSize(DWORD* piIcon); 109 virtual HRESULT STDMETHODCALLTYPE SetBitmap(HBITMAP hBitmap); 110 virtual HRESULT STDMETHODCALLTYPE GetBitmap(HBITMAP* phBitmap); 111 112 // *** IInitializeObject methods *** 113 virtual HRESULT STDMETHODCALLTYPE Initialize(THIS); 114 115 // *** IOleCommandTarget methods *** 116 virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText); 117 virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); 118 119 // *** IServiceProvider methods *** 120 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject); 121 122 // *** IInputObjectSite methods *** 123 virtual HRESULT STDMETHODCALLTYPE OnFocusChangeIS(LPUNKNOWN lpUnknown, BOOL bFocus); 124 125 // *** IInputObject methods *** 126 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL bActivating, LPMSG lpMsg); 127 virtual HRESULT STDMETHODCALLTYPE HasFocusIO(THIS); 128 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg); 129 130 // *** IDeskBar methods *** 131 virtual HRESULT STDMETHODCALLTYPE SetClient(IUnknown *punkClient); 132 virtual HRESULT STDMETHODCALLTYPE GetClient(IUnknown **ppunkClient); 133 virtual HRESULT STDMETHODCALLTYPE OnPosRectChangeDB(LPRECT prc); 134 135 private: 136 // message handlers 137 LRESULT _OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 138 LRESULT _OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 139 LRESULT _OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 140 LRESULT _OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 141 LRESULT _OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 142 LRESULT _OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 143 LRESULT _OnAppActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 144 LRESULT _OnWinIniChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 145 LRESULT _OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 146 LRESULT _OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 147 148 HRESULT _AdjustForTheme(BOOL bFlatStyle); 149 BOOL _IsSubMenuParent(HWND hwnd); 150 HRESULT _CloseBar(); 151 }; 152