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.

164 lines
5.2 KiB

  1. //==============================================================;
  2. //
  3. // This source code is only intended as a supplement to existing Microsoft documentation.
  4. //
  5. //
  6. //
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  9. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  10. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  11. // PURPOSE.
  12. //
  13. // Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  14. //
  15. //
  16. //
  17. //==============================================================;
  18. #include "PPgeExt.h"
  19. #include "resource.h"
  20. #include "globals.h"
  21. #include <crtdbg.h>
  22. // we need to do this to get around MMC.IDL - it explicitly defines
  23. // the clipboard formats as WCHAR types...
  24. #define _T_CCF_DISPLAY_NAME _T("CCF_DISPLAY_NAME")
  25. #define _T_CCF_NODETYPE _T("CCF_NODETYPE")
  26. #define _T_CCF_SNAPIN_CLASSID _T("CCF_SNAPIN_CLASSID")
  27. // These are the clipboard formats that we must supply at a minimum.
  28. // mmc.h actually defined these. We can make up our own to use for
  29. // other reasons. We don't need any others at this time.
  30. UINT CPropSheetExtension::s_cfDisplayName = RegisterClipboardFormat(_T_CCF_DISPLAY_NAME);
  31. UINT CPropSheetExtension::s_cfNodeType = RegisterClipboardFormat(_T_CCF_NODETYPE);
  32. UINT CPropSheetExtension::s_cfSnapInCLSID = RegisterClipboardFormat(_T_CCF_SNAPIN_CLASSID);
  33. CPropSheetExtension::CPropSheetExtension() : m_cref(0)
  34. {
  35. OBJECT_CREATED
  36. }
  37. CPropSheetExtension::~CPropSheetExtension()
  38. {
  39. OBJECT_DESTROYED
  40. }
  41. ///////////////////////
  42. // IUnknown implementation
  43. ///////////////////////
  44. STDMETHODIMP CPropSheetExtension::QueryInterface(REFIID riid, LPVOID *ppv)
  45. {
  46. if (!ppv)
  47. return E_FAIL;
  48. *ppv = NULL;
  49. if (IsEqualIID(riid, IID_IUnknown))
  50. *ppv = static_cast<IExtendPropertySheet *>(this);
  51. else if (IsEqualIID(riid, IID_IExtendPropertySheet))
  52. *ppv = static_cast<IExtendPropertySheet *>(this);
  53. if (*ppv)
  54. {
  55. reinterpret_cast<IUnknown *>(*ppv)->AddRef();
  56. return S_OK;
  57. }
  58. return E_NOINTERFACE;
  59. }
  60. STDMETHODIMP_(ULONG) CPropSheetExtension::AddRef()
  61. {
  62. return InterlockedIncrement((LONG *)&m_cref);
  63. }
  64. STDMETHODIMP_(ULONG) CPropSheetExtension::Release()
  65. {
  66. if (InterlockedDecrement((LONG *)&m_cref) == 0)
  67. {
  68. // we need to decrement our object count in the DLL
  69. delete this;
  70. return 0;
  71. }
  72. return m_cref;
  73. }
  74. BOOL CALLBACK CPropSheetExtension::DialogProc(
  75. HWND hwndDlg, // handle to dialog box
  76. UINT uMsg, // message
  77. WPARAM wParam, // first message parameter
  78. LPARAM lParam // second message parameter
  79. )
  80. {
  81. static CPropSheetExtension *pThis = NULL;
  82. switch (uMsg) {
  83. case WM_INITDIALOG:
  84. pThis = reinterpret_cast<CPropSheetExtension *>(reinterpret_cast<PROPSHEETPAGE *>(lParam)->lParam);
  85. break;
  86. case WM_COMMAND:
  87. if (HIWORD(wParam) == EN_CHANGE ||
  88. HIWORD(wParam) == CBN_SELCHANGE)
  89. SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
  90. break;
  91. case WM_DESTROY:
  92. // we don't free the notify handle for property sheets
  93. // MMCFreeNotifyHandle(pThis->m_ppHandle);
  94. break;
  95. case WM_NOTIFY:
  96. switch (((NMHDR *) lParam)->code) {
  97. case PSN_APPLY:
  98. // don't notify the primary snap-in that Apply
  99. // has been hit...
  100. // MMCPropertyChangeNotify(pThis->m_ppHandle, (long)pThis);
  101. return PSNRET_NOERROR;
  102. }
  103. break;
  104. }
  105. return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
  106. }
  107. ///////////////////////////////
  108. // Interface IExtendPropertySheet
  109. ///////////////////////////////
  110. HRESULT CPropSheetExtension::CreatePropertyPages(
  111. /* [in] */ LPPROPERTYSHEETCALLBACK lpProvider,
  112. /* [in] */ LONG_PTR handle,
  113. /* [in] */ LPDATAOBJECT lpIDataObject)
  114. {
  115. PROPSHEETPAGE psp;
  116. HPROPSHEETPAGE hPage = NULL;
  117. // we don't cache this handle like in a primary snap-in
  118. // the handle value here is always 0
  119. // m_ppHandle = handle;
  120. psp.dwSize = sizeof(PROPSHEETPAGE);
  121. psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEICONID;
  122. psp.hInstance = g_hinst;
  123. psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_LARGE);
  124. psp.pfnDlgProc = DialogProc;
  125. psp.lParam = reinterpret_cast<LPARAM>(this);
  126. psp.pszTitle = MAKEINTRESOURCE(IDS_PST_ROCKET_EXT);
  127. psp.pszIcon = MAKEINTRESOURCE(IDI_PSI_ROCKET);
  128. hPage = CreatePropertySheetPage(&psp);
  129. _ASSERT(hPage);
  130. HRESULT hr = lpProvider->AddPage(hPage);
  131. return hr;
  132. }
  133. HRESULT CPropSheetExtension::QueryPagesFor(
  134. /* [in] */ LPDATAOBJECT lpDataObject)
  135. {
  136. return S_OK;
  137. }