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.

160 lines
6.1 KiB

  1. #ifndef _DVTASKS_H
  2. #define _DVTASKS_H
  3. #include <runtask.h>
  4. class CDefView;
  5. class CGetIconTask;
  6. class CStatusBarAndInfoTipTask;
  7. class CDUIInfotipTask;
  8. class CTestCacheTask;
  9. class CBackgroundInfoTip; // Used for the background processing of InfoTips
  10. STDAPI CCategoryTask_Create(CDefView *pView, LPCITEMIDLIST pidl, UINT uId, IRunnableTask **ppTask);
  11. STDAPI CBkgrndEnumTask_CreateInstance(CDefView *pdsv, IEnumIDList * peunk, HDPA hdpaNew, BOOL fRefresh, IRunnableTask **ppTask);
  12. STDAPI CIconOverlayTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pdl, int iList, IRunnableTask **ppTask);
  13. STDAPI CExtendedColumnTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pidl, UINT uId, int fmt, UINT uiColumn, IRunnableTask **ppTask);
  14. STDAPI CFileTypePropertiesTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pidl, UINT uMaxPropertiesToShow, UINT uId, IRunnableTask **ppTask);
  15. STDAPI CStatusBarAndInfoTipTask_CreateInstance(LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidl, UINT uMsg, int nMsgParam, CBackgroundInfoTip *pbit, HWND hwnd, IShellTaskScheduler2* pScheduler, CStatusBarAndInfoTipTask ** ppTask);
  16. STDAPI CDUIInfotipTask_CreateInstance(CDefView *pDefView, HWND hwndContaining, UINT uToolID, LPCITEMIDLIST pidl, CDUIInfotipTask **ppTask);
  17. STDAPI CTestCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  18. IExtractImage * pExtract, LPCWSTR pszPath, FILETIME ftDateStamp,
  19. LPCITEMIDLIST pidl, int iItem, DWORD dwFlags, DWORD dwPriority,
  20. BOOL fAsync, BOOL fBackground, BOOL fForce, CTestCacheTask **ppTask);
  21. HRESULT CDiskCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  22. DWORD dwPriority, int iItem, LPCITEMIDLIST pidl, LPCWSTR pszPath,
  23. FILETIME ftDateStamp, IExtractImage *pExtract, DWORD dwFlags, IRunnableTask **ppTask);
  24. HRESULT CExtractImageTask_Create(DWORD dwTaskID, CDefView* pView,
  25. IExtractImage *pExtract, LPCWSTR pszPath, LPCITEMIDLIST pidl,
  26. FILETIME fNewTimeStamp, int iItem,
  27. DWORD dwFlags, DWORD dwPriority, IRunnableTask **ppTask);
  28. HRESULT CWriteCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  29. LPCWSTR pszFullPath, FILETIME ftTimeStamp, HBITMAP hImage, IRunnableTask **ppTask);
  30. HRESULT CReadAheadTask_Create(CDefView *pView, IRunnableTask **ppTask);
  31. HRESULT CGetCommandStateTask_Create(CDefView *pView, IUICommand *puiCommand,IShellItemArray *psiItemArray, IRunnableTask **ppTask);
  32. class CTestCacheTask : public CRunnableTask
  33. {
  34. public:
  35. CTestCacheTask(DWORD dwTaskID, CDefView *pView, IExtractImage *pExtract, LPCWSTR pszPath,
  36. FILETIME ftDateStamp, int iItem, DWORD dwFlags, DWORD dwPriority,
  37. BOOL fAsync, BOOL fBackground, BOOL fForce);
  38. STDMETHOD (RunInitRT)();
  39. HRESULT Init(LPCITEMIDLIST pidl);
  40. protected:
  41. ~CTestCacheTask();
  42. CDefView *_pView;
  43. IExtractImage * _pExtract;
  44. WCHAR _szPath[MAX_PATH];
  45. FILETIME _ftDateStamp;
  46. LPITEMIDLIST _pidl;
  47. int _iItem;
  48. DWORD _dwFlags;
  49. DWORD _dwPriority;
  50. BOOL _fAsync;
  51. BOOL _fBackground;
  52. BOOL _fForce;
  53. DWORD _dwTaskID;
  54. };
  55. // task used to perform the background status bar update
  56. class CStatusBarAndInfoTipTask : public CRunnableTask
  57. {
  58. public:
  59. CStatusBarAndInfoTipTask(HRESULT *phr, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidl, UINT uMsg, int nMsgParam, CBackgroundInfoTip *pbit, HWND hwnd, IShellTaskScheduler2* pScheduler);
  60. STDMETHODIMP RunInitRT(void);
  61. protected:
  62. ~CStatusBarAndInfoTipTask();
  63. LPITEMIDLIST _pidl;
  64. LPITEMIDLIST _pidlFolder;
  65. UINT _uMsg;
  66. int _nMsgParam;
  67. CBackgroundInfoTip *_pbit;
  68. HWND _hwnd;
  69. IShellTaskScheduler2* _pScheduler;
  70. };
  71. class CBackgroundInfoTip : IUnknown
  72. {
  73. public:
  74. CBackgroundInfoTip(HRESULT *phr, NMLVGETINFOTIP *plvGetInfoTip)
  75. {
  76. _lvSetInfoTip.cbSize = sizeof(_lvSetInfoTip);
  77. _lvSetInfoTip.iItem = plvGetInfoTip->iItem;
  78. _lvSetInfoTip.iSubItem = plvGetInfoTip->iSubItem;
  79. *phr = SHStrDup(plvGetInfoTip->pszText, &_lvSetInfoTip.pszText);
  80. if (SUCCEEDED(*phr))
  81. {
  82. // Do not repeat the text if the item is not folded
  83. if (plvGetInfoTip->dwFlags & LVGIT_UNFOLDED)
  84. _lvSetInfoTip.pszText[0] = 0;
  85. }
  86. _cRef = 1;
  87. }
  88. // IUnknown
  89. virtual STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj) { return E_NOINTERFACE; }
  90. virtual STDMETHODIMP_(ULONG) AddRef(void)
  91. {
  92. return InterlockedIncrement(&_cRef);
  93. }
  94. virtual STDMETHODIMP_(ULONG) Release(void)
  95. {
  96. if (InterlockedDecrement(&_cRef))
  97. return _cRef;
  98. delete this;
  99. return 0;
  100. }
  101. LVSETINFOTIP _lvSetInfoTip;
  102. BOOL _fReady; // This ensures that we will not try to use the object before it's ready
  103. // CONSIDER: the memory can be released and then re-used by the same object
  104. // CONSIDER: which would have us believe that the InfoTip should be shown.
  105. // CONSIDER: But if another InfoTip had been requested and the memory re-used for the new CBackgroundInfoTip
  106. // CONSIDER: we would handle the message WM_AEB_ASYNCNAVIGATION with an
  107. // CONSIDER: unprocessed CBackgroundInfoTip object. (See the handler for WM_AEB_ASYNCNAVIGATION).
  108. private:
  109. LONG _cRef;
  110. ~CBackgroundInfoTip()
  111. {
  112. CoTaskMemFree(_lvSetInfoTip.pszText); // NULL ok
  113. }
  114. };
  115. class CDUIInfotipTask : public CRunnableTask
  116. {
  117. public:
  118. CDUIInfotipTask() : CRunnableTask(RTF_DEFAULT) {}
  119. // Local
  120. HRESULT Initialize(CDefView *pDefView, HWND hwndContaining, UINT uToolID, LPCITEMIDLIST pidl);
  121. // IRunnableTask
  122. STDMETHOD(RunInitRT)(void);
  123. protected:
  124. virtual ~CDUIInfotipTask();
  125. CDefView * _pDefView;
  126. HWND _hwndContaining; // hwnd containing tool
  127. UINT _uToolID; // tool id (unique among tools in containing hwnd)
  128. LPITEMIDLIST _pidl;
  129. };
  130. #endif