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.

182 lines
3.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: menusp.cxx
  7. //
  8. // Contents: Implementation of IContextMenu
  9. //
  10. // History: 20-Dec-95 BruceFo Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "headers.hxx"
  14. #pragma hdrstop
  15. #include "util.hxx"
  16. #include "dutil.hxx"
  17. #include "menusp.hxx"
  18. #include "menuutil.hxx"
  19. #include "shares.h"
  20. #include "resource.h"
  21. #ifdef WIZARDS
  22. CSharesCMSpecial::CSharesCMSpecial(
  23. IN HWND hwnd
  24. )
  25. :
  26. m_pszMachine(NULL),
  27. m_ulRefs(0),
  28. m_hwnd(hwnd),
  29. m_pidl(NULL),
  30. m_psf(NULL)
  31. {
  32. AddRef();
  33. }
  34. HRESULT
  35. CSharesCMSpecial::InitInstance(
  36. IN PWSTR pszMachine,
  37. IN LPCITEMIDLIST pidl,
  38. IN IShellFolder* psf
  39. )
  40. {
  41. m_pszMachine = pszMachine;
  42. m_pidl = ILClone(pidl);
  43. if (NULL == m_pidl)
  44. {
  45. return E_OUTOFMEMORY;
  46. }
  47. m_psf = psf;
  48. m_psf->AddRef();
  49. return S_OK;
  50. }
  51. CSharesCMSpecial::~CSharesCMSpecial()
  52. {
  53. ILFree(m_pidl);
  54. m_pidl = NULL;
  55. m_psf->Release();
  56. m_psf = NULL;
  57. m_pszMachine = NULL;
  58. }
  59. STDMETHODIMP
  60. CSharesCMSpecial::QueryContextMenu(
  61. HMENU hmenu,
  62. UINT indexMenu,
  63. UINT idCmdFirst,
  64. UINT idCmdLast,
  65. UINT uFlags
  66. )
  67. {
  68. UINT idMerge;
  69. if (uFlags & CMF_DVFILE)
  70. {
  71. idMerge = POPUP_SPECIAL_FILE;
  72. }
  73. else
  74. {
  75. idMerge = POPUP_SPECIAL;
  76. }
  77. QCMINFO qcm = { hmenu, indexMenu, idCmdFirst, idCmdLast };
  78. MyMergeMenu(g_hInstance, idMerge, 0, &qcm);
  79. SetMenuDefaultItem(hmenu, idCmdFirst + FSIDM_OPENSPECIAL, FALSE);
  80. return ResultFromShort(qcm.idCmdFirst - idCmdFirst);
  81. }
  82. STDMETHODIMP
  83. CSharesCMSpecial::InvokeCommand(
  84. LPCMINVOKECOMMANDINFO lpici
  85. )
  86. {
  87. HRESULT hr = S_OK;
  88. LPIDSHARE pids;
  89. UINT i;
  90. UINT idCmd = (UINT)LOWORD((DWORD)lpici->lpVerb);
  91. if (HIWORD(lpici->lpVerb))
  92. {
  93. // Deal with string commands
  94. PSTR pszCmd = (PSTR)lpici->lpVerb;
  95. // Check for "link" that comes from the toolbar or the shell view.
  96. if (0 == lstrcmpA(pszCmd, "link"))
  97. {
  98. idCmd = SHARED_FILE_LINK;
  99. }
  100. else
  101. {
  102. return E_INVALIDARG;
  103. }
  104. }
  105. switch(idCmd)
  106. {
  107. case FSIDM_OPENSPECIAL:
  108. {
  109. pids = (LPIDSHARE)m_pidl;
  110. hr = ShareDoSpecial(m_hwnd, m_pszMachine, Share_GetFlags(pids));
  111. CHECK_HRESULT(hr);
  112. break;
  113. }
  114. case SHARED_FILE_LINK:
  115. {
  116. UINT dwfInOut = 0;
  117. IDataObject* pDataObject;
  118. hr = m_psf->GetUIObjectOf(
  119. lpici->hwnd,
  120. 1,
  121. (LPCITEMIDLIST*)&m_pidl,
  122. IID_IDataObject,
  123. &dwfInOut,
  124. (LPVOID*)&pDataObject);
  125. if (SUCCEEDED(hr))
  126. {
  127. SHCreateLinks(
  128. lpici->hwnd,
  129. NULL,
  130. pDataObject,
  131. SHCL_USETEMPLATE,
  132. NULL);
  133. pDataObject->Release();
  134. }
  135. break;
  136. }
  137. } // switch(wParam)
  138. return hr;
  139. }
  140. STDMETHODIMP
  141. CSharesCMSpecial::GetCommandString(
  142. UINT_PTR idCmd,
  143. UINT uType,
  144. UINT * pwReserved,
  145. LPSTR pszName,
  146. UINT cchMax
  147. )
  148. {
  149. *((LPWSTR)pszName) = TEXT('\0');
  150. if (uType == GCS_HELPTEXT)
  151. {
  152. LoadStringW(g_hInstance, idCmd + IDS_MH_FSIDM_FIRST, (LPWSTR)pszName, cchMax);
  153. return NOERROR;
  154. }
  155. return E_FAIL;
  156. }
  157. #endif // WIZARDS