Source code of Windows XP (NT5)
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.

137 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I C O M T A R G . C P P
  7. //
  8. // Contents: ICommandTarget implementation for IUPnPTray
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 20 Jan 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "tfind.h" // for tray init functions, etc.
  18. #include "upnptray.h"
  19. extern CONST TCHAR c_szMainWindowClassName[];
  20. HRESULT CUPnPTray::QueryStatus(
  21. const GUID * pguidCmdGroup,
  22. ULONG cCmds,
  23. OLECMD prgCmds[],
  24. OLECMDTEXT * pCmdText)
  25. {
  26. HRESULT hr = E_NOTIMPL;
  27. TraceTag(ttidShellFolderIface, "OBJ: CCT - IOleCommandTarget::QueryStatus");
  28. TraceHr(ttidError, FAL, hr, (hr == E_NOTIMPL), "CUPnPTray::QueryStatus");
  29. return hr;
  30. }
  31. HRESULT CUPnPTray::Exec(
  32. const GUID * pguidCmdGroup,
  33. DWORD nCmdID,
  34. DWORD nCmdexecopt,
  35. VARIANTARG * pvaIn,
  36. VARIANTARG * pvaOut)
  37. {
  38. HRESULT hr = S_OK;
  39. TraceTag(ttidShellFolderIface, "OBJ: CCT - IOleCommandTarget::Exec");
  40. if (IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject))
  41. {
  42. // Handle Shell Service Object notifications here.
  43. switch (nCmdID)
  44. {
  45. case SSOCMDID_OPEN:
  46. TraceTag(ttidShellFolder, "The Net Connections Tray is being initialized");
  47. hr = HrHandleTrayOpen();
  48. break;
  49. case SSOCMDID_CLOSE:
  50. TraceTag(ttidShellFolder, "The Net Connections Tray is being destroyed");
  51. hr = HrHandleTrayClose();
  52. break;
  53. default:
  54. hr = S_OK;
  55. break;
  56. }
  57. }
  58. TraceHr(ttidError, FAL, hr, FALSE, "CUPnPTray::Exec");
  59. return hr;
  60. }
  61. //+---------------------------------------------------------------------------
  62. //
  63. // Member: CUPnPTray::HrHandleTrayOpen
  64. //
  65. // Purpose: Handler for the Net Connections Tray object ::Exec call
  66. // SSOCMDID_OPEN command
  67. //
  68. // Arguments:
  69. // (none)
  70. //
  71. // Returns:
  72. //
  73. // Author: jeffspr 7 Jan 1998
  74. //
  75. // Notes:
  76. //
  77. HRESULT CUPnPTray::HrHandleTrayOpen()
  78. {
  79. HRESULT hr = S_OK;
  80. m_hwnd = StartUPnPTray();
  81. if (!m_hwnd)
  82. {
  83. TraceError("CUPnPTray::HrHandleTrayOpen - could not create tray "
  84. "window", hr);
  85. hr = E_FAIL;
  86. }
  87. TraceHr(ttidError, FAL, hr, FALSE, "CUPnPTray::HrHandleTrayOpen()");
  88. return hr;
  89. }
  90. //+---------------------------------------------------------------------------
  91. //
  92. // Member: CUPnPTray::HrHandleTrayClose
  93. //
  94. // Purpose: Handler for the Net Connections Tray object ::Exec call
  95. // SSOCMDID_CLOSE command
  96. //
  97. // Arguments:
  98. // (none)
  99. //
  100. // Returns:
  101. //
  102. // Author: jeffspr 7 Jan 1998
  103. //
  104. // Notes:
  105. //
  106. HRESULT CUPnPTray::HrHandleTrayClose()
  107. {
  108. HRESULT hr = S_OK;
  109. UnregisterClass (c_szMainWindowClassName,
  110. _Module.GetResourceInstance());
  111. if (m_hwnd)
  112. {
  113. DestroyWindow(m_hwnd);
  114. }
  115. TraceHr(ttidError, FAL, hr, FALSE, "CUPnPTray::HrHandleTrayClose()");
  116. return hr;
  117. }