1 /* 2 * PROJECT: ReactOS Search Shell Extension 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Search UI 5 * COPYRIGHT: Copyright 2019 Brock Mammen 6 */ 7 8 #pragma once 9 10 #include "shellfind.h" 11 12 class CSearchBar : 13 public CComCoClass<CSearchBar, &CLSID_FileSearchBand>, 14 public CComObjectRootEx<CComMultiThreadModelNoCS>, 15 public IDeskBand, 16 public IObjectWithSite, 17 public IInputObject, 18 public IPersistStream, 19 public IDispatch, 20 public CDialogImpl<CSearchBar> 21 { 22 23 private: 24 // *** BaseBarSite information *** 25 CComPtr<IUnknown> m_pSite; 26 CComPtr<IAddressEditBox> m_AddressEditBox; 27 BOOL m_bVisible; 28 29 HRESULT GetSearchResultsFolder(IShellBrowser **ppShellBrowser, HWND *pHwnd, IShellFolder **ppShellFolder); 30 BOOL GetAddressEditBoxPath(WCHAR *szPath); 31 void SetSearchInProgress(BOOL bInProgress); 32 HRESULT TrySubscribeToSearchEvents(); 33 34 // *** ATL event handlers *** 35 LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 36 LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 37 LRESULT OnSearchButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 38 LRESULT OnStopButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled); 39 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); 40 41 public: 42 CSearchBar(); 43 virtual ~CSearchBar(); 44 45 // *** IOleWindow methods *** 46 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd); 47 virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); 48 49 // *** IDockingWindow methods *** 50 virtual HRESULT STDMETHODCALLTYPE CloseDW(DWORD dwReserved); 51 virtual HRESULT STDMETHODCALLTYPE ResizeBorderDW(const RECT *prcBorder, IUnknown *punkToolbarSite, BOOL fReserved); 52 virtual HRESULT STDMETHODCALLTYPE ShowDW(BOOL fShow); 53 54 // *** IDeskBand methods *** 55 virtual HRESULT STDMETHODCALLTYPE GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi); 56 57 // *** IObjectWithSite methods *** 58 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite); 59 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite); 60 61 // *** IInputObject methods *** 62 virtual HRESULT STDMETHODCALLTYPE UIActivateIO(BOOL fActivate, LPMSG lpMsg); 63 virtual HRESULT STDMETHODCALLTYPE HasFocusIO(); 64 virtual HRESULT STDMETHODCALLTYPE TranslateAcceleratorIO(LPMSG lpMsg); 65 66 // *** IPersist methods *** 67 virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); 68 69 // *** IPersistStream methods *** 70 virtual HRESULT STDMETHODCALLTYPE IsDirty(); 71 virtual HRESULT STDMETHODCALLTYPE Load(IStream *pStm); 72 virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty); 73 virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize); 74 75 // *** IDispatch methods *** 76 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); 77 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); 78 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); 79 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); 80 81 enum { IDD = IDD_SEARCH_DLG }; 82 83 DECLARE_REGISTRY_RESOURCEID(IDR_EXPLORERBAND) 84 DECLARE_NOT_AGGREGATABLE(CSearchBar) 85 86 DECLARE_PROTECT_FINAL_CONSTRUCT() 87 88 BEGIN_COM_MAP(CSearchBar) 89 COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch) 90 COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents, IDispatch) 91 COM_INTERFACE_ENTRY_IID(DIID_DSearchCommandEvents, IDispatch) 92 COM_INTERFACE_ENTRY2_IID(IID_IOleWindow, IOleWindow, IDeskBand) 93 COM_INTERFACE_ENTRY2_IID(IID_IDockingWindow, IDockingWindow, IDeskBand) 94 COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand) 95 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 96 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject) 97 COM_INTERFACE_ENTRY2_IID(IID_IPersist, IPersist, IPersistStream) 98 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream) 99 END_COM_MAP() 100 101 BEGIN_MSG_MAP(CSearchBar) 102 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 103 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) 104 MESSAGE_HANDLER(WM_SIZE, OnSize) 105 COMMAND_HANDLER(IDC_SEARCH_BUTTON, BN_CLICKED, OnSearchButtonClicked) 106 COMMAND_HANDLER(IDC_SEARCH_STOP_BUTTON, BN_CLICKED, OnStopButtonClicked) 107 END_MSG_MAP() 108 }; 109