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 STDMETHOD(GetWindow)(HWND *lphwnd) override; 47 STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) override; 48 49 // *** IDockingWindow methods *** 50 STDMETHOD(CloseDW)(DWORD dwReserved) override; 51 STDMETHOD(ResizeBorderDW)(const RECT *prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) override; 52 STDMETHOD(ShowDW)(BOOL fShow) override; 53 54 // *** IDeskBand methods *** 55 STDMETHOD(GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi) override; 56 57 // *** IObjectWithSite methods *** 58 STDMETHOD(SetSite)(IUnknown *pUnkSite) override; 59 STDMETHOD(GetSite)(REFIID riid, void **ppvSite) override; 60 61 // *** IInputObject methods *** 62 STDMETHOD(UIActivateIO)(BOOL fActivate, LPMSG lpMsg) override; 63 STDMETHOD(HasFocusIO)() override; 64 STDMETHOD(TranslateAcceleratorIO)(LPMSG lpMsg) override; 65 66 // *** IPersist methods *** 67 STDMETHOD(GetClassID)(CLSID *pClassID) override; 68 69 // *** IPersistStream methods *** 70 STDMETHOD(IsDirty)() override; 71 STDMETHOD(Load)(IStream *pStm) override; 72 STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty) override; 73 STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) override; 74 75 // *** IDispatch methods *** 76 STDMETHOD(GetTypeInfoCount)(UINT *pctinfo) override; 77 STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) override; 78 STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) override; 79 STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) override; 80 81 enum { IDD = IDD_SEARCH_DLG }; 82 83 DECLARE_REGISTRY_RESOURCEID(IDR_FILESEARCHBAND) 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