ctxmenu.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  19. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  20. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  21. // PARTICULAR PURPOSE.
  22. //
  23. // Copyright (C) 1993-1997 Microsoft Corporation. All Rights Reserved.
  24. //
  25. // MODULE: ctxmenu.cpp
  26. //
  27. // PURPOSE: Implements the IContextMenu member functions necessary to support
  28. // the context menu portioins of this shell extension. Context menu
  29. // shell extensions are called when the user right clicks on a file
  30. // (of the type registered for the shell extension--see SHELLEXT.REG
  31. // for details on the registry entries. In this sample, the relevant
  32. // files are of type .W3D) in the Explorer, or selects the File menu
  33. // item.
  34. //
  35. #include "Stdafx.h"
  36. #include "priv.h"
  37. #include "shellext.h"
  38. //
  39. // FUNCTION: CShellExt::QueryContextMenu(HMENU, UINT, UINT, UINT, UINT)
  40. //
  41. // PURPOSE: Called by the shell just before the context menu is displayed.
  42. // This is where you add your specific menu items.
  43. //
  44. // PARAMETERS:
  45. // hMenu - Handle to the context menu
  46. // indexMenu - Index of where to begin inserting menu items
  47. // idCmdFirst - Lowest value for new menu ID's
  48. // idCmtLast - Highest value for new menu ID's
  49. // uFlags - Specifies the context of the menu event
  50. //
  51. // RETURN VALUE:
  52. //
  53. //
  54. // COMMENTS:
  55. //
  56. STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
  57. UINT indexMenu,
  58. UINT idCmdFirst,
  59. UINT idCmdLast,
  60. UINT uFlags){
  61. UINT idCmd = idCmdFirst;
  62. char szMenuText[64];
  63. BOOL bAppendItems=TRUE;
  64. if ((uFlags & 0x000F) == CMF_NORMAL){ //Check == here, since CMF_NORMAL=0
  65. lstrcpy(szMenuText, "&Convert to P3D");
  66. } else{
  67. if (uFlags & CMF_VERBSONLY){
  68. lstrcpy(szMenuText, "&Convert to P3D");
  69. }else{
  70. if (uFlags & CMF_EXPLORE){
  71. lstrcpy(szMenuText, "&Convert to P3D");
  72. }else{
  73. if (uFlags & CMF_DEFAULTONLY){
  74. bAppendItems = FALSE;
  75. }else{
  76. char szTemp[32];
  77. wsprintf(szTemp, "uFlags==>%d\r\n", uFlags);
  78. bAppendItems = FALSE;
  79. }
  80. }
  81. }
  82. }
  83. if (bAppendItems){
  84. InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
  85. InsertMenu(hMenu, indexMenu,MF_STRING|MF_BYPOSITION,idCmd++, szMenuText);
  86. return ResultFromShort(idCmd-idCmdFirst); //Must return number of menu items we added.
  87. }
  88. return NOERROR;
  89. }
  90. STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
  91. {
  92. HRESULT hr = E_INVALIDARG;
  93. //If HIWORD(lpcmi->lpVerb) then we have been called programmatically
  94. //and lpVerb is a command that should be invoked. Otherwise, the shell
  95. //has called us, and LOWORD(lpcmi->lpVerb) is the menu ID the user has
  96. //selected. Actually, it's (menu ID - idCmdFirst) from QueryContextMenu().
  97. if (!HIWORD(lpcmi->lpVerb)){
  98. UINT idCmd = LOWORD(lpcmi->lpVerb);
  99. switch (idCmd){
  100. case 0:{
  101. hr = DoW3DMenu1(lpcmi->hwnd,lpcmi->lpDirectory,lpcmi->lpVerb,lpcmi->lpParameters, lpcmi->nShow);
  102. break;
  103. }
  104. }
  105. }
  106. return hr;
  107. }
  108. STDMETHODIMP CShellExt::GetCommandString(UINT idCmd,
  109. UINT uFlags,
  110. UINT FAR *reserved,
  111. LPSTR pszName,
  112. UINT cchMax){
  113. switch (idCmd){
  114. case 0:
  115. lstrcpy(pszName, "New menu item number 1");
  116. break;
  117. }
  118. return NOERROR;
  119. }
  120. STDMETHODIMP CShellExt::DoW3DMenu1(HWND hParent,
  121. LPCSTR pszWorkingDir,
  122. LPCSTR pszCmd,
  123. LPCSTR pszParam,
  124. int iShowCmd){
  125. MessageBox(hParent, "Not Implemented !", "Sorry !", MB_OK);
  126. return NOERROR;
  127. }