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.

293 lines
6.0 KiB

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. HRESULT CDeskHtmlProp::QueryInterface(REFIID riid, LPVOID * ppvObj)
  4. {
  5. HRESULT hr = E_NOINTERFACE;
  6. static const QITAB qit[] = {
  7. QITABENT(CDeskHtmlProp, IObjectWithSite),
  8. QITABENT(CDeskHtmlProp, IShellExtInit),
  9. QITABENT(CDeskHtmlProp, IPersist),
  10. QITABENT(CDeskHtmlProp, IPropertyBag),
  11. QITABENT(CDeskHtmlProp, IBasePropPage),
  12. QITABENTMULTI(CDeskHtmlProp, IShellPropSheetExt, IBasePropPage),
  13. { 0 },
  14. };
  15. return QISearch(this, qit, riid, ppvObj);
  16. }
  17. ULONG CDeskHtmlProp::AddRef()
  18. {
  19. _cRef++;
  20. return _cRef;
  21. }
  22. ULONG CDeskHtmlProp::Release()
  23. {
  24. _cRef--;
  25. if (_cRef > 0)
  26. return _cRef;
  27. delete this;
  28. return 0;
  29. }
  30. CDeskHtmlProp::CDeskHtmlProp() : _cRef(1), CObjectCLSID(&PPID_Background)
  31. {
  32. DllAddRef();
  33. OleInitialize(NULL);
  34. _pspseBkgdPage = NULL;
  35. }
  36. CDeskHtmlProp::~CDeskHtmlProp()
  37. {
  38. ATOMICRELEASE(_pspseBkgdPage);
  39. OleUninitialize();
  40. DllRelease();
  41. }
  42. HRESULT CDeskHtmlProp::_InitBackgroundTab(void)
  43. {
  44. HRESULT hr = S_OK;
  45. if (!_pspseBkgdPage)
  46. {
  47. CBackPropSheetPage * pbpsp = new CBackPropSheetPage();
  48. hr = E_OUTOFMEMORY;
  49. if (pbpsp)
  50. {
  51. hr = pbpsp->QueryInterface(IID_PPV_ARG(IShellPropSheetExt, &_pspseBkgdPage));
  52. pbpsp->Release();
  53. }
  54. else
  55. {
  56. TraceMsg(TF_WARNING, "DeskHtml - ReplacePage could not create a page");
  57. }
  58. }
  59. return hr;
  60. }
  61. // *** IObjectWithSite ***
  62. HRESULT CDeskHtmlProp::SetSite(IN IUnknown * punkSite)
  63. {
  64. HRESULT hr = _InitBackgroundTab();
  65. if (SUCCEEDED(hr))
  66. {
  67. hr = IUnknown_SetSite(_pspseBkgdPage, punkSite);
  68. }
  69. return hr;
  70. }
  71. HRESULT CDeskHtmlProp::GetSite(IN REFIID riid, OUT void ** ppvSite)
  72. {
  73. HRESULT hr = _InitBackgroundTab();
  74. if (SUCCEEDED(hr))
  75. {
  76. IObjectWithSite * punk;
  77. hr = _pspseBkgdPage->QueryInterface(IID_PPV_ARG(IObjectWithSite, &punk));
  78. if (SUCCEEDED(hr))
  79. {
  80. hr = punk->GetSite(riid, ppvSite);
  81. punk->Release();
  82. }
  83. }
  84. return hr;
  85. }
  86. // *** IShellExtInit ***
  87. HRESULT CDeskHtmlProp::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pdtobj, HKEY hkeyProgID)
  88. {
  89. TraceMsg(TF_GENERAL, "DeskHtmlProp - Initialize");
  90. HRESULT hr = E_INVALIDARG;
  91. // Forward on to the Background tab (CBackPropSheetPage)
  92. hr = _InitBackgroundTab();
  93. if (SUCCEEDED(hr))
  94. {
  95. IShellExtInit * pShellExtInt;
  96. if (SUCCEEDED(_pspseBkgdPage->QueryInterface(IID_PPV_ARG(IShellExtInit, &pShellExtInt))))
  97. {
  98. hr = pShellExtInt->Initialize(pidlFolder, pdtobj, hkeyProgID);
  99. pShellExtInt->Release();
  100. }
  101. }
  102. return hr;
  103. }
  104. // *** IBasePropPage ***
  105. HRESULT CDeskHtmlProp::GetAdvancedDialog(OUT IAdvancedDialog ** ppAdvDialog)
  106. {
  107. HRESULT hr = E_INVALIDARG;
  108. // Forward on to the Background tab (CBackPropSheetPage)
  109. if (ppAdvDialog)
  110. {
  111. *ppAdvDialog = NULL;
  112. hr = _InitBackgroundTab();
  113. if (SUCCEEDED(hr))
  114. {
  115. IBasePropPage * pBasePage;
  116. hr = _pspseBkgdPage->QueryInterface(IID_PPV_ARG(IBasePropPage, &pBasePage));
  117. if (SUCCEEDED(hr))
  118. {
  119. hr = pBasePage->GetAdvancedDialog(ppAdvDialog);
  120. pBasePage->Release();
  121. }
  122. }
  123. }
  124. return hr;
  125. }
  126. HRESULT CDeskHtmlProp::OnApply(IN PROPPAGEONAPPLY oaAction)
  127. {
  128. HRESULT hr = _InitBackgroundTab();
  129. if (SUCCEEDED(hr))
  130. {
  131. IBasePropPage * pBasePage;
  132. hr = _pspseBkgdPage->QueryInterface(IID_PPV_ARG(IBasePropPage, &pBasePage));
  133. if (SUCCEEDED(hr))
  134. {
  135. hr = pBasePage->OnApply(oaAction);
  136. pBasePage->Release();
  137. }
  138. }
  139. return hr;
  140. }
  141. // *** IPropertyBag ***
  142. HRESULT CDeskHtmlProp::Read(IN LPCOLESTR pszPropName, IN VARIANT * pVar, IN IErrorLog *pErrorLog)
  143. {
  144. HRESULT hr = _InitBackgroundTab();
  145. if (SUCCEEDED(hr))
  146. {
  147. IPropertyBag * pPropertyBag;
  148. hr = _pspseBkgdPage->QueryInterface(IID_PPV_ARG(IPropertyBag, &pPropertyBag));
  149. if (SUCCEEDED(hr))
  150. {
  151. hr = pPropertyBag->Read(pszPropName, pVar, pErrorLog);
  152. pPropertyBag->Release();
  153. }
  154. }
  155. return hr;
  156. }
  157. HRESULT CDeskHtmlProp::Write(IN LPCOLESTR pszPropName, IN VARIANT *pVar)
  158. {
  159. HRESULT hr = _InitBackgroundTab();
  160. if (SUCCEEDED(hr))
  161. {
  162. IPropertyBag * pPropertyBag;
  163. hr = _pspseBkgdPage->QueryInterface(IID_PPV_ARG(IPropertyBag, &pPropertyBag));
  164. if (SUCCEEDED(hr))
  165. {
  166. hr = pPropertyBag->Write(pszPropName, pVar);
  167. pPropertyBag->Release();
  168. }
  169. }
  170. return hr;
  171. }
  172. // *** IShellPropSheetExt ***
  173. HRESULT CDeskHtmlProp::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
  174. {
  175. TraceMsg(TF_GENERAL, "DeskHtmlProp - ReplacePage");
  176. RegisterBackPreviewClass();
  177. HRESULT hr = _InitBackgroundTab();
  178. if (SUCCEEDED(hr))
  179. {
  180. hr = _pspseBkgdPage->AddPages(lpfnAddPage, lParam);
  181. }
  182. return hr;
  183. }
  184. typedef struct tagREPLACEPAGE_LPARAM
  185. {
  186. void * pvDontTouch;
  187. IThemeUIPages * ptuiPages;
  188. } REPLACEPAGE_LPARAM;
  189. //-----------------------------------------------------------------------------
  190. //
  191. // _PSXACALLINFO
  192. //
  193. // used to forward LPFNADDPROPSHEETPAGE calls with added error checking
  194. //
  195. //-----------------------------------------------------------------------------
  196. typedef struct
  197. {
  198. LPFNADDPROPSHEETPAGE pfn;
  199. LPARAM lparam;
  200. UINT count;
  201. BOOL allowmulti;
  202. BOOL alreadycalled;
  203. } _PSXACALLINFO;
  204. HRESULT CDeskHtmlProp::ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
  205. {
  206. return S_OK;
  207. }
  208. HRESULT CDeskHtmlProp_CreateInstance(LPUNKNOWN punkOuter, REFIID riid, void **ppvOut)
  209. {
  210. TraceMsg(TF_GENERAL, "DeskHtmlProp - CreateInstance");
  211. CDeskHtmlProp* pdhd = new CDeskHtmlProp();
  212. if (pdhd)
  213. {
  214. HRESULT hres = pdhd->QueryInterface(riid, ppvOut);
  215. pdhd->Release();
  216. return hres;
  217. }
  218. *ppvOut = NULL;
  219. return E_OUTOFMEMORY;
  220. }