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.

144 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: menubg.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 "menubg.hxx"
  17. #include "menuutil.hxx"
  18. #include "resource.h"
  19. STDMETHODIMP
  20. CSharesCMBG::QueryContextMenu(
  21. HMENU hmenu,
  22. UINT indexMenu,
  23. UINT idCmdFirst,
  24. UINT idCmdLast,
  25. UINT uFlags
  26. )
  27. {
  28. UINT idMainMerge;
  29. if (uFlags & CMF_DVFILE)
  30. {
  31. // This IContextMenu was created to add items to the DefView menu.
  32. // We only want to add a "new" item to the "File" menu, so set don't
  33. // do any "main" merge.
  34. idMainMerge = 0;
  35. }
  36. else
  37. {
  38. // In this case, it's actually a background right-click context menu,
  39. // so merge in the "New" menu.
  40. idMainMerge = POPUP_SHARESBG_POPUPMERGE2;
  41. }
  42. QCMINFO qcm = { hmenu, indexMenu, idCmdFirst, idCmdLast };
  43. switch (m_level)
  44. {
  45. case 1:
  46. MyMergeMenu(
  47. g_hInstance,
  48. 0,
  49. POPUP_SHARESBG_POPUPMERGE1,
  50. &qcm);
  51. break;
  52. case 2:
  53. MyMergeMenu(
  54. g_hInstance,
  55. idMainMerge,
  56. POPUP_SHARESBG_POPUPMERGE2,
  57. &qcm);
  58. break;
  59. default: appAssert(FALSE);
  60. }
  61. return ResultFromShort(qcm.idCmdFirst - idCmdFirst);
  62. }
  63. STDMETHODIMP
  64. CSharesCMBG::InvokeCommand(
  65. LPCMINVOKECOMMANDINFO lpici
  66. )
  67. {
  68. if (HIWORD(lpici->lpVerb))
  69. {
  70. // Deal with string commands
  71. return E_INVALIDARG;
  72. }
  73. appAssert(ICOL1_NAME == ICOL2_NAME);
  74. appAssert(ICOL1_COMMENT == ICOL2_COMMENT);
  75. UINT idCmd = (UINT)LOWORD(lpici->lpVerb);
  76. switch (idCmd)
  77. {
  78. case FSIDM_SORTBYNAME:
  79. ShellFolderView_ReArrange(m_hwnd, ICOL2_NAME);
  80. return NOERROR;
  81. case FSIDM_SORTBYCOMMENT:
  82. ShellFolderView_ReArrange(m_hwnd, ICOL2_COMMENT);
  83. return NOERROR;
  84. case FSIDM_SORTBYPATH:
  85. appAssert(m_level >= 2);
  86. ShellFolderView_ReArrange(m_hwnd, ICOL2_PATH);
  87. return NOERROR;
  88. case FSIDM_SORTBYMAXUSES:
  89. appAssert(m_level >= 2);
  90. ShellFolderView_ReArrange(m_hwnd, ICOL2_MAXUSES);
  91. return NOERROR;
  92. case FSIDM_NEWSHARE:
  93. {
  94. appAssert(m_level >= 2);
  95. // pass in a pointer to our own IUnknown
  96. IUnknown* punk;
  97. HRESULT hr = QueryInterface(IID_IUnknown, (LPVOID*)&punk);
  98. if (SUCCEEDED(hr))
  99. {
  100. hr = ShareDoNew(punk, m_pszMachine);
  101. punk->Release();
  102. }
  103. return hr;
  104. }
  105. default:
  106. return E_INVALIDARG;
  107. }
  108. }
  109. STDMETHODIMP
  110. CSharesCMBG::GetCommandString(
  111. UINT_PTR idCmd,
  112. UINT uType,
  113. UINT * pwReserved,
  114. LPSTR pszName,
  115. UINT cchMax
  116. )
  117. {
  118. *((LPWSTR)pszName) = TEXT('\0');
  119. if (uType == GCS_HELPTEXT)
  120. {
  121. LoadStringW(g_hInstance, (UINT)(idCmd + IDS_MH_FSIDM_FIRST), (LPWSTR)pszName, cchMax);
  122. return NOERROR;
  123. }
  124. return E_FAIL;
  125. }