Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

343 lines
13 KiB

  1. // findband.h : Declaration of the CFileSearchBand
  2. #ifndef __FSEARCH_H__
  3. #define __FSEARCH_H__
  4. #include "unicpp/stdafx.h"
  5. #include "atldisp.h"
  6. #include "shcombox.h" // shell combo methods
  7. #include "finddlg.h"
  8. class CFindFilesDlg;
  9. #define FILESEARCHCTL_CLASS TEXT("ShellFileSearchControl")
  10. // Band layout flags passed thru CFileSearchBand::UpdateLayout().
  11. #define BLF_CALCSCROLL 0x00000001 // recalc scroll bars
  12. #define BLF_SCROLLWINDOW 0x00000002 // scroll subdialog
  13. #define BLF_RESIZECHILDREN 0x00000004 // resize subdialog
  14. #define BLF_ALL 0xFFFFFFFF // do all layout ops
  15. const UINT _icons[] = {
  16. // replaced icons for fsearch, csearch with riff animations.
  17. IDI_PSEARCH,
  18. };
  19. // CMetrics: maintains ctl metrics and resources.
  20. class CMetrics
  21. {
  22. public:
  23. CMetrics();
  24. ~CMetrics()
  25. {
  26. DestroyResources();
  27. }
  28. void Init(HWND hwndDlg);
  29. void OnWinIniChange(HWND hwndDlg);
  30. static COLORREF TextColor() { return GetSysColor(COLOR_WINDOWTEXT); }
  31. static COLORREF BkgndColor() { return GetSysColor(COLOR_WINDOW); }
  32. static COLORREF BorderColor() { return GetSysColor(COLOR_WINDOWTEXT); }
  33. const HBRUSH& BkgndBrush() const { return _hbrBkgnd; }
  34. const HBRUSH& BorderBrush() const { return _hbrBorder; }
  35. POINT& ExpandOrigin() { return _ptExpandOrigin; }
  36. RECT& CheckBoxRect() { return _rcCheckBox; }
  37. int& TightMarginY() { return _cyTightMargin; }
  38. int& LooseMarginY() { return _cyLooseMargin; }
  39. int& CtlMarginX() { return _cxCtlMargin; }
  40. HFONT BoldFont(HWND hwndDlg);
  41. HICON CaptionIcon(UINT nIDIconResource);
  42. protected:
  43. BOOL CreateResources();
  44. VOID DestroyResources();
  45. static BOOL GetWindowLogFont(HWND hwnd, OUT LOGFONT* plf);
  46. HBRUSH _hbrBkgnd;
  47. HBRUSH _hbrBorder;
  48. POINT _ptExpandOrigin; // left-top origin of subdlg expansion
  49. RECT _rcCheckBox; // size of a check box
  50. int _cyTightMargin; // v. distance between two tightly associated controls.
  51. int _cyLooseMargin; // v. distance between two loosely associated controls.
  52. int _cxCtlMargin; // distance between left or right dlg border and child window border.
  53. HFONT _hfBold; // Bold font
  54. HICON _rghiconCaption[ARRAYSIZE(_icons)];
  55. };
  56. class ATL_NO_VTABLE CFileSearchBand :
  57. public CComObjectRootEx<CComSingleThreadModel>,
  58. public CComCoClass<CFileSearchBand, &CLSID_FileSearchBand>,
  59. public CComControl<CFileSearchBand>,
  60. public CStockPropImpl<CFileSearchBand, IFileSearchBand, &IID_IFileSearchBand, &LIBID_Shell32>,
  61. public IProvideClassInfo2Impl<&CLSID_FileSearchBand, NULL, &LIBID_Shell32>,
  62. public IPersistStreamInitImpl<CFileSearchBand>,
  63. public IPersistStorageImpl<CFileSearchBand>,
  64. public IQuickActivateImpl<CFileSearchBand>,
  65. public IOleControlImpl<CFileSearchBand>,
  66. public IOleInPlaceActiveObjectImpl<CFileSearchBand>,
  67. public IViewObjectExImpl<CFileSearchBand>,
  68. public IOleInPlaceObjectWindowlessImpl<CFileSearchBand>,
  69. public IDataObjectImpl<CFileSearchBand>,
  70. public ISpecifyPropertyPagesImpl<CFileSearchBand>,
  71. public IDeskBand,
  72. public IObjectWithSite,
  73. public IPersistStream,
  74. public IInputObject,
  75. public IServiceProvider,
  76. public IOleCommandTarget,
  77. // Must derive from CShell32AtlIDispatch<> and not IOleObjecImpl
  78. // if this control resides in shell32.dll
  79. public CShell32AtlIDispatch<CFileSearchBand, &CLSID_FileSearchBand, &IID_IFileSearchBand, &LIBID_Shell32, 1, 0, CComTypeInfoHolder>
  80. {
  81. public:
  82. CFileSearchBand();
  83. ~CFileSearchBand();
  84. static CWndClassInfo& GetWndClassInfo();
  85. HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName = NULL,
  86. DWORD dwStyle = WS_CHILD|WS_VISIBLE, DWORD dwExStyle = 0, UINT nID = 0);
  87. void SetDeskbandWidth(int cx);
  88. void FinalRelease();
  89. public:
  90. BOOL IsDeskBand() const { return _fDeskBand; }
  91. static BOOL IsBandDebut();
  92. CMetrics& GetMetrics() { return _metrics; }
  93. static int MakeBandKey(OUT LPTSTR pszKey, IN UINT cchKey);
  94. static int MakeBandSubKey(IN LPCTSTR pszSubKey, OUT LPTSTR pszKey, IN UINT cchKey);
  95. static HKEY GetBandRegKey(BOOL bForceCreate = FALSE);
  96. void UpdateLayout(ULONG fLayoutFlags = BLF_ALL);
  97. void EnsureVisible(LPCRECT lprc /* in screen coords */);
  98. BOOL IsKeyboardScroll(MSG* pmsg);
  99. HRESULT IsDlgMessage(HWND hwnd, LPMSG pmsg);
  100. HRESULT AutoActivate();
  101. void SetDirty(BOOL bDirty = TRUE);
  102. BOOL IsDirty() const { return _fDirty; }
  103. BOOL IsValid() const { return _fValid; }
  104. IUnknown* BandSite() { return _punkSite ? _punkSite : (IUnknown*)m_spClientSite; }
  105. IOleClientSite* OleClientSite() { return m_spClientSite; }
  106. DECLARE_NO_REGISTRY();
  107. BEGIN_COM_MAP(CFileSearchBand)
  108. COM_INTERFACE_ENTRY(IFileSearchBand)
  109. COM_INTERFACE_ENTRY(IDispatch)
  110. COM_INTERFACE_ENTRY(IViewObjectEx)
  111. COM_INTERFACE_ENTRY_IID(IID_IViewObject2, IViewObjectEx)
  112. COM_INTERFACE_ENTRY_IID(IID_IViewObject, IViewObjectEx)
  113. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  114. COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  115. COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  116. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  117. COM_INTERFACE_ENTRY(IOleControl)
  118. COM_INTERFACE_ENTRY(IOleObject)
  119. COM_INTERFACE_ENTRY(IQuickActivate)
  120. COM_INTERFACE_ENTRY(IPersistStorage)
  121. //COM_INTERFACE_ENTRY(IPersistStreamInit)
  122. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  123. COM_INTERFACE_ENTRY(IDataObject)
  124. COM_INTERFACE_ENTRY(IProvideClassInfo)
  125. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  126. COM_INTERFACE_ENTRY_IID(IID_IDeskBand,IDeskBand)
  127. COM_INTERFACE_ENTRY(IOleCommandTarget)
  128. COM_INTERFACE_ENTRY_IID(IID_IInputObject,IInputObject)
  129. COM_INTERFACE_ENTRY(IObjectWithSite)
  130. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  131. COM_INTERFACE_ENTRY(IPersistStream)
  132. END_COM_MAP()
  133. public:
  134. BEGIN_PROPERTY_MAP(CFileSearchBand)
  135. // PROP_ENTRY("Property Description", dispid, clsid)
  136. PROP_PAGE(CLSID_StockColorPage)
  137. END_PROPERTY_MAP()
  138. // message map
  139. BEGIN_MSG_MAP(CFileSearchBand)
  140. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  141. MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
  142. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  143. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  144. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  145. MESSAGE_HANDLER(WM_SIZE, OnSize)
  146. MESSAGE_HANDLER(WM_HSCROLL, OnScroll)
  147. MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
  148. MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
  149. MESSAGE_HANDLER(WM_SETTINGCHANGE, OnWinIniChange)
  150. MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnWinIniChange)
  151. MESSAGE_HANDLER(WM_WININICHANGE, OnWinIniChange)
  152. MESSAGE_HANDLER(WMU_BANDINFOUPDATE, OnBandInfoUpdate)
  153. END_MSG_MAP()
  154. //---------------------//
  155. // Message handling
  156. protected:
  157. LRESULT OnCreate(UINT, WPARAM, LPARAM, BOOL&);
  158. LRESULT OnScroll(UINT, WPARAM, LPARAM, BOOL&);
  159. LRESULT OnEraseBkgnd(UINT, WPARAM, LPARAM, BOOL&);
  160. LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL&);
  161. LRESULT OnMouseActivate(UINT, WPARAM, LPARAM, BOOL&);
  162. LRESULT OnWinIniChange(UINT, WPARAM, LPARAM, BOOL&);
  163. LRESULT OnBandInfoUpdate(UINT, WPARAM, LPARAM, BOOL&);
  164. public:
  165. // IFileSearchBand methods
  166. STDMETHOD (SetFocus)();
  167. STDMETHOD (SetSearchParameters)(IN BSTR* pbstrSearchID,
  168. IN VARIANT_BOOL bNavToResults,
  169. IN OPTIONAL VARIANT *pvarScope,
  170. IN OPTIONAL VARIANT* pvarQueryFile);
  171. STDMETHOD (get_SearchID)(OUT BSTR* pbstrSearchID);
  172. STDMETHOD (get_Scope)(OUT VARIANT *pvarScope);
  173. STDMETHOD (get_QueryFile)(OUT VARIANT *pvarFile);
  174. STDMETHOD (FindFilesOrFolders)(BOOL bNavigateToResults = FALSE,
  175. BOOL bDefaultFocusCtl = FALSE);
  176. STDMETHOD (FindComputer)(BOOL bNavigateToResults = FALSE,
  177. BOOL bDefaultFocusCtl = FALSE);
  178. STDMETHOD (FindPrinter) (BOOL bNavigateToResults = FALSE,
  179. BOOL bDefaultFocusCtl = FALSE);
  180. STDMETHOD (FindPeople) (BOOL bNavigateToResults = FALSE,
  181. BOOL bDefaultFocusCtl = FALSE);
  182. STDMETHOD (FindOnWeb) (BOOL bNavigateToResults = FALSE,
  183. BOOL bDefaultFocusCtl = FALSE);
  184. HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; }
  185. STDMETHOD (SetObjectRects)(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
  186. // CShell32AtlIDispatch/IOleObject methods
  187. STDMETHOD (PrivateQI)(REFIID iid, void** ppvObject);
  188. STDMETHOD (DoVerbUIActivate)(LPCRECT prcPosRect, HWND hwndParent);
  189. STDMETHOD (TranslateAcceleratorInternal)(MSG *pMsg, IOleClientSite * pocs);
  190. // IViewObjectEx methods
  191. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  192. {
  193. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  194. *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
  195. return S_OK;
  196. }
  197. // IOleInPlaceActiveObject methods
  198. STDMETHOD (TranslateAccelerator)(LPMSG lpmsg);
  199. // IDeskBand
  200. STDMETHOD (GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi);
  201. // IDockingWindow
  202. STDMETHOD (ShowDW)(BOOL fShow);
  203. STDMETHOD (CloseDW)(DWORD dwReserved);
  204. STDMETHOD (ResizeBorderDW)(LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
  205. // IOleWindow
  206. STDMETHOD (GetWindow)(HWND * lphwnd) { *lphwnd = m_hWnd; return ::IsWindow(m_hWnd) ? S_OK : S_FALSE; }
  207. STDMETHOD (ContextSensitiveHelp)(BOOL fEnterMode) { return E_NOTIMPL; }
  208. // IObjectWithSite
  209. STDMETHOD (SetSite)(IUnknown* punkSite);
  210. STDMETHOD (GetSite)(REFIID riid, void** ppunkSite);
  211. // IInputObject
  212. STDMETHOD (HasFocusIO)(void);
  213. STDMETHOD (TranslateAcceleratorIO)(LPMSG lpMsg);
  214. STDMETHOD (UIActivateIO)(BOOL fActivate, LPMSG lpMsg);
  215. // IOleCommandTarget
  216. STDMETHOD (QueryStatus)(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText);
  217. STDMETHOD (Exec)(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  218. // IServiceProvider
  219. STDMETHOD (QueryService)(REFGUID guidService, REFIID riid, void** ppv);
  220. // IPersist
  221. STDMETHOD (GetClassID)(CLSID *pClassID); //
  222. // IPersistStream
  223. STDMETHOD (IsDirty)(void);
  224. STDMETHOD (Load)(IStream *pStm); //
  225. STDMETHOD (Save)(IStream *pStm, BOOL fClearDirty); //
  226. STDMETHOD (GetSizeMax)(ULARGE_INTEGER *pcbSize);
  227. BOOL SearchInProgress() const
  228. {
  229. if (_pBandDlg)
  230. return _pBandDlg->SearchInProgress();
  231. return FALSE;
  232. };
  233. void StopSearch()
  234. {
  235. if (_pBandDlg)
  236. _pBandDlg->StopSearch();
  237. };
  238. private:
  239. CBandDlg* GetBandDialog(REFGUID guidSearch);
  240. HRESULT ShowBandDialog(REFGUID guidSearch,
  241. BOOL bNavigateToResults = FALSE,
  242. BOOL bDefaultFocusCtl = FALSE /* force focus to the band's default control */);
  243. HRESULT AdvertiseBand(BOOL bAdvertise);
  244. HRESULT BandInfoChanged();
  245. void AddButtons(BOOL);
  246. BOOL LoadImageLists();
  247. void LayoutControls(int cx, int cy, ULONG fLayoutFlags = BLF_ALL);
  248. void EnableControls();
  249. void Scroll(int nBar, UINT uSBCode, int nNewPos = 0);
  250. IShellBrowser* GetTopLevelBrowser();
  251. BOOL IsBrowserAccelerator(LPMSG pmsg);
  252. CBandDlg* BandDlg();
  253. CFindFilesDlg _dlgFSearch;
  254. CFindComputersDlg _dlgCSearch;
  255. #ifdef __PSEARCH_BANDDLG__
  256. CFindPrintersDlg _dlgPSearch;
  257. #endif __PSEARCH_BANDDLG__
  258. CBandDlg* _pBandDlg; // the active/visible band.
  259. GUID _guidSearch; // the GUID of the active/visible band.
  260. CMetrics _metrics;
  261. SIZE _sizeMin,
  262. _sizeMax;
  263. IUnknown* _punkSite;
  264. SCROLLINFO _siHorz,
  265. _siVert;
  266. BITBOOL _fValid : 1,
  267. _fDirty : 1,
  268. _fDeskBand : 1,
  269. _fStrings : 1;
  270. DWORD _dwBandID,
  271. _dwBandViewMode;
  272. HIMAGELIST _hilHot, // toolbar image lists
  273. _hilDefault;
  274. IShellBrowser* _psb; // top-level browser.
  275. LONG_PTR _cbOffset;
  276. BOOL _bSendFinishedDisplaying; // Have we sent FileType box message to start new thread?
  277. };
  278. // Index Server control
  279. // these are in ntquery.h
  280. // Query dialects:
  281. #ifndef ISQLANG_V1
  282. #define ISQLANG_V1 1
  283. #endif //ISQLANG_V1
  284. #ifndef ISQLANG_V2
  285. #define ISQLANG_V2 2
  286. #endif //ISQLANG_V2
  287. STDAPI GetCIStatus(BOOL *pbRunning, BOOL *pbIndexed, BOOL *pbPermission);
  288. STDAPI CatalogUptodate(LPCWSTR pszCatalog, LPCWSTR pszMachine);
  289. STDAPI StartStopCI(BOOL bStart);
  290. STDAPI_(BOOL) IsCiQuery(const VARIANT* pvarRaw, OUT VARIANT* pvarQuery, OUT ULONG* pulDialect);
  291. #endif //__FSEARCH_H__