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.

98 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2002.
  5. //
  6. // File: App.cpp
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. // App.cpp : Implementation of CSendConsoleMessageApp snapin
  12. #include "stdafx.h"
  13. #include "debug.h"
  14. #include "util.h"
  15. #include "resource.h"
  16. #include "SendCMsg.h"
  17. #include "dialogs.h"
  18. #include "App.h"
  19. // Menu IDs
  20. #define cmSendConsoleMessage 100 // Menu Command Id to invoke the dialog
  21. #if !defined(UNICODE)
  22. #error This project requires UNICODE to be defined
  23. #endif
  24. #define IID_PPV_ARG(Type, Expr) IID_##Type, \
  25. reinterpret_cast<void**>(static_cast<Type **>(Expr))
  26. /////////////////////////////////////////////////////////////////////
  27. // CSendConsoleMessageApp::IExtendContextMenu::AddMenuItems()
  28. STDMETHODIMP
  29. CSendConsoleMessageApp::AddMenuItems(
  30. IN IDataObject * /*pDataObject*/,
  31. OUT IContextMenuCallback * pContextMenuCallback,
  32. INOUT long * /*pInsertionAllowed*/)
  33. {
  34. HRESULT hr = S_OK;
  35. if ( !pContextMenuCallback )
  36. return E_POINTER;
  37. do {
  38. CComPtr<IContextMenuCallback2> spContextMenuCallback2;
  39. hr = pContextMenuCallback->QueryInterface (IID_PPV_ARG (IContextMenuCallback2, &spContextMenuCallback2));
  40. if ( FAILED (hr) )
  41. break;
  42. if ( !spContextMenuCallback2 )
  43. {
  44. hr = E_NOTIMPL;
  45. break;
  46. }
  47. CONTEXTMENUITEM cmiSeparator = { 0 };
  48. cmiSeparator.lInsertionPointID = CCM_INSERTIONPOINTID_3RDPARTY_TASK;
  49. cmiSeparator.fSpecialFlags = CCM_SPECIAL_SEPARATOR;
  50. hr = pContextMenuCallback->AddItem(IN &cmiSeparator);
  51. WCHAR szMenuItem[128];
  52. WCHAR szStatusBarText[256];
  53. CchLoadString(IDS_MENU_SEND_MESSAGE, OUT szMenuItem, LENGTH(szMenuItem));
  54. CchLoadString(IDS_STATUS_SEND_MESSAGE, OUT szStatusBarText, LENGTH(szStatusBarText));
  55. CONTEXTMENUITEM2 cmi = { 0 };
  56. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_3RDPARTY_TASK;
  57. cmi.lCommandID = cmSendConsoleMessage;
  58. cmi.strName = szMenuItem;
  59. cmi.strStatusBarText = szStatusBarText;
  60. cmi.strLanguageIndependentName = L"_SENDCONSOLEMESSAGE"; // not to be localized
  61. hr = spContextMenuCallback2->AddItem(IN &cmi);
  62. if ( FAILED (hr) )
  63. break;
  64. hr = pContextMenuCallback->AddItem(IN &cmiSeparator);
  65. } while (0);
  66. return S_OK;
  67. }
  68. /////////////////////////////////////////////////////////////////////
  69. // CSendConsoleMessageApp::IExtendContextMenu::Command()
  70. STDMETHODIMP
  71. CSendConsoleMessageApp::Command(LONG lCommandID, IDataObject * pDataObject)
  72. {
  73. if (lCommandID == cmSendConsoleMessage)
  74. {
  75. (void)DoDialogBox(
  76. IDD_SEND_CONSOLE_MESSAGE,
  77. ::GetActiveWindow(),
  78. CSendConsoleMessageDlg::DlgProc,
  79. (LPARAM)pDataObject);
  80. }
  81. return S_OK;
  82. }