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.

169 lines
3.1 KiB

  1. /*+
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RDPRemoteDesktopClientHost
  5. Abstract:
  6. Author:
  7. Tad Brockway 02/00
  8. Revision History:
  9. --*/
  10. #include "stdafx.h"
  11. #ifdef TRC_FILE
  12. #undef TRC_FILE
  13. #endif
  14. #define TRC_FILE "_crdph"
  15. #include "RDCHost.h"
  16. #include "TSRDPRemoteDesktopClient.h"
  17. #include "RemoteDesktopClientHost.h"
  18. #include <RemoteDesktopUtils.h>
  19. ///////////////////////////////////////////////////////
  20. //
  21. // CRemoteDesktopClientHost Methods
  22. //
  23. HRESULT
  24. CRemoteDesktopClientHost::FinalConstruct()
  25. {
  26. DC_BEGIN_FN("CRemoteDesktopClientHost::FinalConstruct");
  27. HRESULT hr = S_OK;
  28. if (!AtlAxWinInit()) {
  29. TRC_ERR((TB, L"AtlAxWinInit failed."));
  30. hr = E_FAIL;
  31. }
  32. DC_END_FN();
  33. return hr;
  34. }
  35. HRESULT
  36. CRemoteDesktopClientHost::Initialize(
  37. LPCREATESTRUCT pCreateStruct
  38. )
  39. /*++
  40. Routine Description:
  41. Final Initialization
  42. Arguments:
  43. pCreateStruct - WM_CREATE, create struct.
  44. Return Value:
  45. S_OK on success. Otherwise, an error code is returned.
  46. --*/
  47. {
  48. DC_BEGIN_FN("CRemoteDesktopClientHost::Initialize");
  49. RECT rcClient = { 0, 0, pCreateStruct->cx, pCreateStruct->cy };
  50. HRESULT hr;
  51. IUnknown *pUnk = NULL;
  52. ASSERT(!m_Initialized);
  53. //
  54. // Create the client Window.
  55. //
  56. m_ClientWnd = m_ClientAxView.Create(
  57. m_hWnd, rcClient, REMOTEDESKTOPCLIENT_TEXTGUID,
  58. WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, 0
  59. );
  60. if (m_ClientWnd == NULL) {
  61. hr = HRESULT_FROM_WIN32(GetLastError());
  62. TRC_ERR((TB, L"Window Create: %08X", GetLastError()));
  63. goto CLEANUPANDEXIT;
  64. }
  65. ASSERT(::IsWindow(m_ClientWnd));
  66. //
  67. // Get IUnknown
  68. //
  69. hr = AtlAxGetControl(m_ClientWnd, &pUnk);
  70. if (!SUCCEEDED(hr)) {
  71. TRC_ERR((TB, L"AtlAxGetControl: %08X", hr));
  72. pUnk = NULL;
  73. goto CLEANUPANDEXIT;
  74. }
  75. //
  76. // Get the client control.
  77. //
  78. hr = pUnk->QueryInterface(__uuidof(ISAFRemoteDesktopClient), (void**)&m_Client);
  79. if (!SUCCEEDED(hr)) {
  80. TRC_ERR((TB, L"QueryInterface: %08X", hr));
  81. goto CLEANUPANDEXIT;
  82. }
  83. m_Initialized = TRUE;
  84. CLEANUPANDEXIT:
  85. //
  86. // m_Client keeps our reference to the client object until
  87. // the destructor is called.
  88. //
  89. if (pUnk != NULL) {
  90. pUnk->Release();
  91. }
  92. DC_END_FN();
  93. return hr;
  94. }
  95. STDMETHODIMP
  96. CRemoteDesktopClientHost::GetRemoteDesktopClient(
  97. ISAFRemoteDesktopClient **client
  98. )
  99. /*++
  100. Routine Description:
  101. Arguments:
  102. Return Value:
  103. S_OK on success. Otherwise, an error code is returned.
  104. --*/
  105. {
  106. DC_BEGIN_FN("CRemoteDesktopClientHost::GetRemoteDesktopClient");
  107. HRESULT hr;
  108. ASSERT(m_Initialized);
  109. if (m_Client != NULL) {
  110. hr = m_Client->QueryInterface(__uuidof(ISAFRemoteDesktopClient), (void **)client);
  111. }
  112. else {
  113. hr = E_FAIL;
  114. }
  115. DC_END_FN();
  116. return hr;
  117. }