1 /* 2 * ReactOS Explorer 3 * 4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org> 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #pragma once 22 23 #define ITBARSTREAM_SHELLBROWSER 0 24 #define ITBARSTREAM_WEBBROWSER 1 25 #define ITBARSTREAM_EXPLORER 2 26 27 static const int gSearchCommandID = 1003; 28 static const int gFoldersCommandID = 1004; 29 static const int gMoveToCommandID = FCIDM_SHVIEW_MOVETO; 30 static const int gCopyToCommandID = FCIDM_SHVIEW_COPYTO; 31 static const int gDeleteCommandID = FCIDM_SHVIEW_DELETE; 32 static const int gUndoCommandID = FCIDM_SHVIEW_UNDO; 33 static const int gViewsCommandID = FCIDM_SHVIEW_AUTOARRANGE; 34 static const int gStopCommandID = 1010; 35 static const int gHomeCommandID = 1012; 36 static const int gFavoritesCommandID = 1015; 37 static const int gHistoryCommandID = 1016; 38 static const int gFullScreenCommandID = 1017; 39 static const int gPropertiesCommandID = FCIDM_SHVIEW_PROPERTIES; 40 static const int gCutCommandID = FCIDM_SHVIEW_CUT; 41 static const int gCopyCommandID = FCIDM_SHVIEW_COPY; 42 static const int gPasteCommandID = FCIDM_SHVIEW_INSERT; 43 44 class CMenuCallback : 45 public CComObjectRootEx<CComMultiThreadModelNoCS>, 46 public IShellMenuCallback 47 { 48 private: 49 CComPtr<IShellMenu> fFavoritesMenu; 50 public: 51 CMenuCallback(); 52 virtual ~CMenuCallback(); 53 54 HRESULT STDMETHODCALLTYPE GetObject(LPSMDATA psmd, REFIID riid, void **ppvObject); 55 public: 56 // *** IShellMenuCallback methods *** 57 virtual HRESULT STDMETHODCALLTYPE CallbackSM(LPSMDATA psmd, UINT uMsg, WPARAM wParam, LPARAM lParam); 58 59 BEGIN_COM_MAP(CMenuCallback) 60 COM_INTERFACE_ENTRY_IID(IID_IShellMenuCallback, IShellMenuCallback) 61 END_COM_MAP() 62 }; 63 64 class CInternetToolbar : 65 public CWindowImpl<CInternetToolbar, CWindow, CControlWinTraits>, 66 public CComCoClass<CInternetToolbar, &CLSID_InternetToolbar>, 67 public CComObjectRootEx<CComMultiThreadModelNoCS>, 68 public IInputObject, 69 public IDockingWindow, 70 public IPersistStreamInit, 71 public IOleCommandTarget, 72 public IDispatch, 73 public IExplorerToolbar, 74 public IShellChangeNotify, 75 public IObjectWithSite, 76 public IServiceProvider, 77 public IWinEventHandler, 78 public IBandSite 79 { 80 public: 81 CComPtr<IUnknown> fSite; // our site 82 HWND fMainReBar; // rebar for top of window 83 bool fLocked; // is bar locked to prevent changes? 84 CComPtr<IShellMenu> fMenuBar; // the menu rebar 85 HWND fMenuBandWindow; 86 HWND fNavigationWindow; 87 CComPtr<IUnknown> fLogoBar; // the reactos logo 88 CComPtr<IUnknown> fControlsBar; // navigation controls 89 CComPtr<IUnknown> fNavigationBar; // address bar 90 CComPtr<CMenuCallback> fMenuCallback; 91 CComPtr<IOleCommandTarget> fCommandTarget; 92 GUID fCommandCategory; 93 HWND fToolbarWindow; 94 DWORD fAdviseCookie; 95 CComPtr<IBandProxy> fBandProxy; 96 BOOL fSizing; 97 POINT fStartPosition; 98 LONG fStartHeight; 99 ShellSettings *pSettings; 100 BOOL fIgnoreChanges; 101 public: 102 CInternetToolbar(); 103 virtual ~CInternetToolbar(); 104 void AddDockItem(IUnknown *newItem, int bandID, int flags); 105 HRESULT EnumBands(UINT Index, int *pBandId, IUnknown **ppUnkBand); 106 HRESULT ReserveBorderSpace(LONG maxHeight = -1); 107 HRESULT CreateMenuBar(IShellMenu **menuBar); 108 HRESULT CreateToolsBar(IUnknown **toolsBar); 109 HRESULT LockUnlockToolbars(bool locked); 110 HRESULT CommandStateChanged(bool newValue, int commandID); 111 HRESULT CreateAndInitBandProxy(); 112 HRESULT IsBandVisible(int BandID); 113 HRESULT SetBandVisibility(int BandID, int Show); 114 HRESULT ToggleBandVisibility(int BandID); 115 HRESULT SetState(const GUID *pguidCmdGroup, long commandID, OLECMD* pcmd); 116 void RefreshLockedToolbarState(); 117 HRESULT SetDirty(); 118 119 static HRESULT GetStream(UINT StreamFor, DWORD Stgm, IStream **ppS); 120 121 public: 122 // *** IInputObject specific methods *** 123 STDMETHOD(UIActivateIO)(BOOL fActivate, LPMSG lpMsg) override; 124 STDMETHOD(HasFocusIO)() override; 125 STDMETHOD(TranslateAcceleratorIO)(LPMSG lpMsg) override; 126 127 // *** IOleWindow methods *** 128 STDMETHOD(GetWindow)(HWND *lphwnd) override; 129 STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) override; 130 131 // *** IDockingWindow methods *** 132 STDMETHOD(ShowDW)(BOOL fShow) override; 133 STDMETHOD(CloseDW)(DWORD dwReserved) override; 134 STDMETHOD(ResizeBorderDW)(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) override; 135 136 // *** IPersist methods *** 137 STDMETHOD(GetClassID)(CLSID *pClassID) override; 138 139 // *** IPersistStreamInit methods *** 140 STDMETHOD(IsDirty)() override; 141 STDMETHOD(Load)(IStream *pStm) override; 142 STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty) override; 143 STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) override; 144 STDMETHOD(InitNew)() override; 145 146 // *** IOleCommandTarget methods *** 147 STDMETHOD(QueryStatus)(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText) override; 148 STDMETHOD(Exec)(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) override; 149 150 // *** IDispatch methods *** 151 STDMETHOD(GetTypeInfoCount)(UINT *pctinfo) override; 152 STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) override; 153 STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) override; 154 STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) override; 155 156 // *** IExplorerToolbar methods *** 157 STDMETHOD(SetCommandTarget)(IUnknown *theTarget, GUID *category, long param14) override; 158 STDMETHOD(Unknown1)() override; 159 STDMETHOD(AddButtons)(const GUID *pguidCmdGroup, long buttonCount, TBBUTTON *buttons) override; 160 STDMETHOD(AddString)(const GUID *pguidCmdGroup, HINSTANCE param10, LPCTSTR param14, long *param18) override; 161 STDMETHOD(GetButton)(const GUID *pguidCmdGroup, long param10, long param14) override; 162 STDMETHOD(GetState)(const GUID *pguidCmdGroup, long commandID, long *theState) override; 163 STDMETHOD(SetState)(const GUID *pguidCmdGroup, long commandID, long theState) override; 164 STDMETHOD(AddBitmap)(const GUID *pguidCmdGroup, long param10, long buttonCount, TBADDBITMAP *lParam, long *newIndex, COLORREF param20) override; 165 STDMETHOD(GetBitmapSize)(long *paramC) override; 166 STDMETHOD(SendToolbarMsg)(const GUID *pguidCmdGroup, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *result) override; 167 STDMETHOD(SetImageList)(const GUID *pguidCmdGroup, HIMAGELIST param10, HIMAGELIST param14, HIMAGELIST param18) override; 168 STDMETHOD(ModifyButton)(const GUID *pguidCmdGroup, long param10, long param14) override; 169 170 // *** IShellChangeNotify methods *** 171 STDMETHOD(OnChange)(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) override; 172 173 // *** IObjectWithSite methods *** 174 STDMETHOD(SetSite)(IUnknown *pUnkSite) override; 175 STDMETHOD(GetSite)(REFIID riid, void **ppvSite) override; 176 177 // *** IServiceProvider methods *** 178 STDMETHOD(QueryService)(REFGUID guidService, REFIID riid, void **ppvObject) override; 179 180 // *** IWinEventHandler methods *** 181 STDMETHOD(OnWinEvent)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult) override; 182 STDMETHOD(IsWindowOwner)(HWND hWnd) override; 183 184 // *** IBandSite specific methods *** 185 STDMETHOD(AddBand)(IUnknown *punk) override; 186 STDMETHOD(EnumBands)(UINT uBand, DWORD *pdwBandID) override; 187 STDMETHOD(QueryBand)(DWORD dwBandID, IDeskBand **ppstb, DWORD *pdwState, LPWSTR pszName, int cchName) override; 188 STDMETHOD(SetBandState)(DWORD dwBandID, DWORD dwMask, DWORD dwState) override; 189 STDMETHOD(RemoveBand)(DWORD dwBandID) override; 190 STDMETHOD(GetBandObject)(DWORD dwBandID, REFIID riid, void **ppv) override; 191 STDMETHOD(SetBandSiteInfo)(const BANDSITEINFO *pbsinfo) override; 192 STDMETHOD(GetBandSiteInfo)(BANDSITEINFO *pbsinfo) override; 193 194 // message handlers 195 LRESULT OnTravelBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 196 LRESULT OnTravelForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 197 LRESULT OnUpLevel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 198 LRESULT OnSearch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 199 LRESULT OnFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 200 LRESULT OnForwardToCommandTarget(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 201 LRESULT OnMenuDropDown(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled); 202 LRESULT OnQueryInsert(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled); 203 LRESULT OnQueryDelete(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled); 204 LRESULT OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 205 LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 206 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 207 LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 208 LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled); 209 LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 210 LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 211 LRESULT OnLDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 212 LRESULT OnLUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 213 LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 214 LRESULT OnWinIniChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 215 LRESULT OnSettingsChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 216 217 BEGIN_MSG_MAP(CInternetToolbar) 218 COMMAND_ID_HANDLER(IDM_GOTO_BACK, OnTravelBack) 219 COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnTravelForward) 220 COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnUpLevel) 221 COMMAND_ID_HANDLER(gSearchCommandID, OnSearch) 222 COMMAND_ID_HANDLER(gFoldersCommandID, OnFolders) 223 COMMAND_RANGE_HANDLER(0x7000, 0x7fff, OnForwardToCommandTarget) 224 NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown) 225 NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert) 226 NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete) 227 MESSAGE_HANDLER(WM_COMMAND, OnCommand) 228 MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu) 229 MESSAGE_HANDLER(WM_SIZE, OnSize) 230 MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) 231 NOTIFY_CODE_HANDLER(TTN_NEEDTEXTW, OnTipText) 232 MESSAGE_HANDLER(WM_NOTIFY, OnNotify) 233 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLDown) 234 MESSAGE_HANDLER(WM_LBUTTONUP, OnLUp) 235 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) 236 MESSAGE_HANDLER(WM_WININICHANGE, OnWinIniChange) 237 MESSAGE_HANDLER(BWM_SETTINGCHANGE, OnSettingsChange) 238 END_MSG_MAP() 239 240 DECLARE_REGISTRY_RESOURCEID(IDR_INTERNETTOOLBAR) 241 DECLARE_NOT_AGGREGATABLE(CInternetToolbar) 242 243 DECLARE_PROTECT_FINAL_CONSTRUCT() 244 245 BEGIN_COM_MAP(CInternetToolbar) 246 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject) 247 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow) 248 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow) 249 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) 250 // COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream) 251 COM_INTERFACE_ENTRY_IID(IID_IPersistStreamInit, IPersistStreamInit) 252 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) 253 COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch) 254 COM_INTERFACE_ENTRY_IID(IID_IExplorerToolbar, IExplorerToolbar) 255 COM_INTERFACE_ENTRY_IID(IID_IShellChangeNotify, IShellChangeNotify) 256 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 257 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider) 258 COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler) 259 COM_INTERFACE_ENTRY_IID(IID_IBandSite, IBandSite) 260 END_COM_MAP() 261 }; 262