Leaked source code of windows server 2003
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.

246 lines
6.5 KiB

  1. /*****************************************************************************
  2. *
  3. * mappsx.c - IShellPropSheetExt interface
  4. *
  5. *****************************************************************************/
  6. #include "map.h"
  7. /*****************************************************************************
  8. *
  9. * The sqiffle for this file.
  10. *
  11. *****************************************************************************/
  12. #define sqfl sqflPsx
  13. /*****************************************************************************
  14. *
  15. * Declare the interfaces we will be providing.
  16. *
  17. * We must implement an IShellExtInit so the shell
  18. * will know that we are ready for action.
  19. *
  20. *****************************************************************************/
  21. Primary_Interface(CMapPsx, IShellPropSheetExt);
  22. Secondary_Interface(CMapPsx, IShellExtInit);
  23. /*****************************************************************************
  24. *
  25. * CMapPsx
  26. *
  27. * The property sheet extension for the Map/Ctrl gizmo.
  28. *
  29. *****************************************************************************/
  30. typedef struct CMapPsx {
  31. /* Supported interfaces */
  32. IShellPropSheetExt psx;
  33. IShellExtInit sxi;
  34. } CMapPsx, CMSX, *PCMSX;
  35. typedef IShellPropSheetExt PSX, *PPSX;
  36. typedef IShellExtInit SXI, *PSXI;
  37. typedef IDataObject DTO, *PDTO; /* Used by IShellExtInit */
  38. /*****************************************************************************
  39. *
  40. * CMapPsx_QueryInterface (from IUnknown)
  41. *
  42. * We need to check for our additional interfaces before falling
  43. * through to Common_QueryInterface.
  44. *
  45. *****************************************************************************/
  46. STDMETHODIMP
  47. CMapPsx_QueryInterface(PPSX ppsx, RIID riid, PPV ppvObj)
  48. {
  49. PCMSX this = IToClass(CMapPsx, psx, ppsx);
  50. HRESULT hres;
  51. if (IsEqualIID(riid, &IID_IShellExtInit)) {
  52. *ppvObj = &this->sxi;
  53. Common_AddRef(this);
  54. hres = S_OK;
  55. } else {
  56. hres = Common_QueryInterface(this, riid, ppvObj);
  57. }
  58. AssertF(fLimpFF(FAILED(hres), *ppvObj == 0));
  59. return hres;
  60. }
  61. /*****************************************************************************
  62. *
  63. * CMapPsx_AddRef (from IUnknown)
  64. * CMapPsx_Release (from IUnknown)
  65. *
  66. *****************************************************************************/
  67. #ifdef DEBUG
  68. Default_AddRef(CMapPsx)
  69. Default_Release(CMapPsx)
  70. #else
  71. #define CMapPsx_AddRef Common_AddRef
  72. #define CMapPsx_Release Common_Release
  73. #endif
  74. /*****************************************************************************
  75. *
  76. * CMapPsx_Finalize (from Common)
  77. *
  78. * Release the resources of an CMapPsx.
  79. *
  80. *****************************************************************************/
  81. void EXTERNAL
  82. CMapPsx_Finalize(PV pv)
  83. {
  84. PCMSX this = pv;
  85. EnterProc(CMapPsx_Finalize, (_ "p", pv));
  86. ExitProc();
  87. }
  88. /*****************************************************************************
  89. *
  90. * CMapPsx_AddPages (From IShellPropSheetExt)
  91. *
  92. * Add one or more pages to an existing property sheet.
  93. *
  94. * lpfnAdd - callback function to add pages
  95. * lp - refdata for lpfnAdd
  96. *
  97. *****************************************************************************/
  98. STDMETHODIMP
  99. CMapPsx_AddPages(PPSX ppsx, LPFNADDPROPSHEETPAGE lpfnAdd, LPARAM lp)
  100. {
  101. PCMSX this = IToClass(CMapPsx, psx, ppsx);
  102. HRESULT hres;
  103. EnterProc(CMapPsx_AddPages, (_ "p", ppsx));
  104. /*
  105. * Add the page only on Windows NT.
  106. */
  107. if ((int)GetVersion() >= 0 && lpfnAdd) {
  108. HPROPSHEETPAGE hpsp;
  109. PROPSHEETPAGE psp;
  110. psp.dwSize = sizeof(psp);
  111. psp.dwFlags = PSP_DEFAULT;
  112. psp.hInstance = g_hinst;
  113. psp.pszTemplate = MAKEINTRESOURCE(IDD_MAIN);
  114. psp.pfnDlgProc = MapPs_DlgProc;
  115. hpsp = CreatePropertySheetPage(&psp);
  116. if (hpsp) {
  117. if (lpfnAdd(hpsp, lp)) {
  118. Common_AddRef(this);
  119. hres = S_OK;
  120. } else {
  121. DestroyPropertySheetPage(hpsp);
  122. hres = E_FAIL;
  123. }
  124. } else {
  125. hres = E_FAIL;
  126. }
  127. } else {
  128. hres = E_INVALIDARG;
  129. }
  130. ExitOleProc();
  131. return hres;
  132. }
  133. /*****************************************************************************
  134. *
  135. * CMapPsx_ReplacePages (From IShellPropSheetExt)
  136. *
  137. * Replaces one or more pages in an existing property sheet.
  138. *
  139. * id - page identifier
  140. * lpfnReplace - callback function to replace the page
  141. * lp - refdata for lpfnReplace
  142. *
  143. *****************************************************************************/
  144. STDMETHODIMP
  145. CMapPsx_ReplacePages(PPSX ppsx, UINT id,
  146. LPFNADDPROPSHEETPAGE lpfnAdd, LPARAM lp)
  147. {
  148. PCMSX this = IToClass(CMapPsx, psx, ppsx);
  149. HRESULT hres;
  150. EnterProc(CMapPsx_ReplacePages, (_ "pu", ppsx, id));
  151. hres = S_OK;
  152. ExitOleProc();
  153. return hres;
  154. }
  155. /*****************************************************************************
  156. *
  157. * CMapPsx_SXI_Initialize (from IShellExtension)
  158. *
  159. *****************************************************************************/
  160. STDMETHODIMP
  161. CMapPsx_SXI_Initialize(PSXI psxi, PCIDL pidlFolder, PDTO pdto, HKEY hk)
  162. {
  163. PCMSX this = IToClass(CMapPsx, sxi, psxi);
  164. HRESULT hres;
  165. EnterProc(CMapPsx_SXI_Initialize, (_ ""));
  166. hres = S_OK;
  167. ExitOleProc();
  168. return hres;
  169. }
  170. /*****************************************************************************
  171. *
  172. * CMapPsx_New (from IClassFactory)
  173. *
  174. * Note that we release the pmpsx that Common_New created, because we
  175. * are done with it. The real refcount is handled by the
  176. * CMapPsx_QueryInterface.
  177. *
  178. *****************************************************************************/
  179. STDMETHODIMP
  180. CMapPsx_New(RIID riid, PPV ppvObj)
  181. {
  182. HRESULT hres;
  183. EnterProc(CMapPsx_New, (_ "G", riid));
  184. *ppvObj = 0;
  185. hres = Common_New(CMapPsx, ppvObj);
  186. if (SUCCEEDED(hres)) {
  187. PCMSX pmpsx = *ppvObj;
  188. pmpsx->sxi.lpVtbl = Secondary_Vtbl(CMapPsx, IShellExtInit);
  189. hres = CMapPsx_QueryInterface(&pmpsx->psx, riid, ppvObj);
  190. Common_Release(pmpsx);
  191. }
  192. ExitOleProcPpv(ppvObj);
  193. return hres;
  194. }
  195. /*****************************************************************************
  196. *
  197. * The long-awaited vtbls
  198. *
  199. *****************************************************************************/
  200. #pragma BEGIN_CONST_DATA
  201. Primary_Interface_Begin(CMapPsx, IShellPropSheetExt)
  202. CMapPsx_AddPages,
  203. CMapPsx_ReplacePages,
  204. Primary_Interface_End(CMapPsx, IIShellPropSheetExt)
  205. Secondary_Interface_Begin(CMapPsx, IShellExtInit, sxi)
  206. CMapPsx_SXI_Initialize,
  207. Secondary_Interface_End(CMapPsx, IShellExtInit, sxi)