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.

275 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RemoteDesktopClientHost
  5. Abstract:
  6. Author:
  7. Tad Brockway 02/00
  8. Revision History:
  9. --*/
  10. #ifndef __REMOTEDESKTOPCLIENTHOST_H_
  11. #define __REMOTEDESKTOPCLIENTHOST_H_
  12. #include <RemoteDesktopTopLevelObject.h>
  13. #include "resource.h"
  14. #include <atlctl.h>
  15. #include "RemoteDesktopClient.h"
  16. ///////////////////////////////////////////////////////
  17. //
  18. // CRemoteDesktopClientHost
  19. //
  20. class ATL_NO_VTABLE CRemoteDesktopClientHost :
  21. public CRemoteDesktopTopLevelObject,
  22. public CComObjectRootEx<CComSingleThreadModel>,
  23. public IDispatchImpl<ISAFRemoteDesktopClientHost, &IID_ISAFRemoteDesktopClientHost, &LIBID_RDCCLIENTHOSTLib>,
  24. public CComControl<CRemoteDesktopClientHost>,
  25. public IPersistStreamInitImpl<CRemoteDesktopClientHost>,
  26. public IOleControlImpl<CRemoteDesktopClientHost>,
  27. public IOleObjectImpl<CRemoteDesktopClientHost>,
  28. public IOleInPlaceActiveObjectImpl<CRemoteDesktopClientHost>,
  29. public IViewObjectExImpl<CRemoteDesktopClientHost>,
  30. public IOleInPlaceObjectWindowlessImpl<CRemoteDesktopClientHost>,
  31. public IConnectionPointContainerImpl<CRemoteDesktopClientHost>,
  32. public IPersistStorageImpl<CRemoteDesktopClientHost>,
  33. public ISpecifyPropertyPagesImpl<CRemoteDesktopClientHost>,
  34. public IQuickActivateImpl<CRemoteDesktopClientHost>,
  35. public IDataObjectImpl<CRemoteDesktopClientHost>,
  36. public IProvideClassInfo2Impl<&CLSID_SAFRemoteDesktopClientHost, NULL, &LIBID_RDCCLIENTHOSTLib>,
  37. public IPropertyNotifySinkCP<CRemoteDesktopClientHost>,
  38. public CComCoClass<CRemoteDesktopClientHost, &CLSID_SAFRemoteDesktopClientHost>
  39. {
  40. private:
  41. ISAFRemoteDesktopClient *m_Client;
  42. HWND m_ClientWnd;
  43. CAxWindow m_ClientAxView;
  44. BOOL m_Initialized;
  45. //
  46. // Final Initialization
  47. //
  48. HRESULT Initialize(LPCREATESTRUCT pCreateStruct);
  49. public:
  50. //
  51. // Constructor/Destructor
  52. //
  53. CRemoteDesktopClientHost()
  54. {
  55. //
  56. // We are window'd, even if our parent supports Windowless
  57. // controls.
  58. //
  59. m_bWindowOnly = TRUE;
  60. m_Client = NULL;
  61. m_ClientWnd = NULL;
  62. m_Initialized = FALSE;
  63. }
  64. ~CRemoteDesktopClientHost()
  65. {
  66. DC_BEGIN_FN("CRemoteDesktopClientHost::~CRemoteDesktopClientHost");
  67. if (m_Client != NULL) {
  68. m_Client->Release();
  69. }
  70. DC_END_FN();
  71. }
  72. HRESULT FinalConstruct();
  73. STDMETHOD(OnFrameWindowActivate)(BOOL fActivate)
  74. {
  75. DC_BEGIN_FN("CRemoteDesktopClientHost::OnFrameWindowActivate");
  76. //
  77. // Set focus back to the client window, if it exists.
  78. //
  79. if (m_ClientWnd != NULL) {
  80. ::SetFocus(m_ClientWnd);
  81. }
  82. DC_END_FN();
  83. return S_OK;
  84. }
  85. DECLARE_REGISTRY_RESOURCEID(IDR_REMOTEDESKTOPCLIENTHOST)
  86. DECLARE_NOT_AGGREGATABLE(CRemoteDesktopClientHost)
  87. DECLARE_PROTECT_FINAL_CONSTRUCT()
  88. //
  89. // COM Interface Map
  90. //
  91. BEGIN_COM_MAP(CRemoteDesktopClientHost)
  92. COM_INTERFACE_ENTRY(ISAFRemoteDesktopClientHost)
  93. COM_INTERFACE_ENTRY(IDispatch)
  94. COM_INTERFACE_ENTRY(IViewObjectEx)
  95. COM_INTERFACE_ENTRY(IViewObject2)
  96. COM_INTERFACE_ENTRY(IViewObject)
  97. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  98. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  99. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  100. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  101. COM_INTERFACE_ENTRY(IOleControl)
  102. COM_INTERFACE_ENTRY(IOleObject)
  103. COM_INTERFACE_ENTRY(IPersistStreamInit)
  104. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  105. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  106. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  107. COM_INTERFACE_ENTRY(IQuickActivate)
  108. COM_INTERFACE_ENTRY(IPersistStorage)
  109. COM_INTERFACE_ENTRY(IDataObject)
  110. COM_INTERFACE_ENTRY(IProvideClassInfo)
  111. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  112. END_COM_MAP()
  113. BEGIN_PROP_MAP(CRemoteDesktopClientHost)
  114. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  115. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  116. // Example entries
  117. // PROP_ENTRY("Property Description", dispid, clsid)
  118. // PROP_PAGE(CLSID_StockColorPage)
  119. END_PROP_MAP()
  120. //
  121. // Connection Point Map
  122. //
  123. BEGIN_CONNECTION_POINT_MAP(CRemoteDesktopClientHost)
  124. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  125. END_CONNECTION_POINT_MAP()
  126. //
  127. // Message Map
  128. //
  129. BEGIN_MSG_MAP(CRemoteDesktopClientHost)
  130. CHAIN_MSG_MAP(CComControl<CRemoteDesktopClientHost>)
  131. DEFAULT_REFLECTION_HANDLER()
  132. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  133. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  134. MESSAGE_HANDLER(WM_SIZE, OnSize)
  135. END_MSG_MAP()
  136. // Handler prototypes:
  137. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  138. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  139. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  140. //
  141. // IViewObjectEx
  142. //
  143. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  144. public:
  145. //
  146. // OnDraw
  147. //
  148. HRESULT OnDraw(ATL_DRAWINFO& di)
  149. {
  150. RECT& rc = *(RECT*)di.prcBounds;
  151. Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
  152. HRESULT hr;
  153. if (!m_Initialized) {
  154. hr = S_OK;
  155. SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
  156. LPCTSTR pszText = _T("Remote Desktop Client Host");
  157. TextOut(di.hdcDraw,
  158. (rc.left + rc.right) / 2,
  159. (rc.top + rc.bottom) / 2,
  160. pszText,
  161. lstrlen(pszText));
  162. }
  163. return hr;
  164. }
  165. //
  166. // OnCreate
  167. //
  168. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  169. {
  170. //
  171. // We are hidden by default.
  172. //
  173. //ShowWindow(SW_HIDE);
  174. DC_BEGIN_FN("CRemoteDesktopClientHost::OnCreate");
  175. if (!m_Initialized) {
  176. //ASSERT(FALSE);
  177. LPCREATESTRUCT pCreateStruct = (LPCREATESTRUCT)lParam;
  178. Initialize(pCreateStruct);
  179. }
  180. DC_END_FN();
  181. return 0;
  182. }
  183. //
  184. // OnSetFocus
  185. //
  186. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  187. {
  188. DC_BEGIN_FN("CRemoteDesktopClientHost::OnSetFocus");
  189. //
  190. // Set focus back to the client window, if it exists.
  191. //
  192. if (m_ClientWnd != NULL) {
  193. ::PostMessage(m_ClientWnd, uMsg, wParam, lParam);
  194. }
  195. DC_END_FN();
  196. return 0;
  197. }
  198. //
  199. // OnSize
  200. //
  201. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  202. {
  203. DC_BEGIN_FN("CRemoteDesktopClientHost::OnSize");
  204. if (m_ClientWnd != NULL) {
  205. RECT rect;
  206. GetClientRect(&rect);
  207. ASSERT(rect.left == 0);
  208. ASSERT(rect.top == 0);
  209. ASSERT(rect.bottom == HIWORD(lParam));
  210. ASSERT(rect.right == LOWORD(lParam));
  211. ::MoveWindow(m_ClientWnd, rect.left, rect.top,
  212. rect.right, rect.bottom, TRUE);
  213. }
  214. DC_END_FN();
  215. return 0;
  216. }
  217. //
  218. // ISAFRemoteDesktopClientHost Methods
  219. //
  220. STDMETHOD(GetRemoteDesktopClient)(ISAFRemoteDesktopClient **client);
  221. //
  222. // Return the name of this class.
  223. //
  224. virtual const LPTSTR ClassName() {
  225. return TEXT("CRemoteDesktopClientHost");
  226. }
  227. };
  228. #endif //__REMOTEDESKTOPCLIENTHOST_H_