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.

115 lines
3.5 KiB

  1. // TaskUI_HTMLControl.h : Declaration of the CTaskUI_HTMLControl
  2. #ifndef __TASKUI_HTMLCONTROL_H_
  3. #define __TASKUI_HTMLCONTROL_H_
  4. #include "resource.h" // main symbols
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CTaskUI_HTMLControl
  7. class ATL_NO_VTABLE CTaskUI_HTMLControl :
  8. public CComObjectRootEx<CComSingleThreadModel>,
  9. public IDispatchImpl<ITaskUI_HTMLControl, &IID_ITaskUI_HTMLControl, &LIBID_TASKUILib>,
  10. public CComControl<CTaskUI_HTMLControl>,
  11. public IOleControlImpl<CTaskUI_HTMLControl>,
  12. public IOleObjectImpl<CTaskUI_HTMLControl>,
  13. public IOleInPlaceActiveObjectImpl<CTaskUI_HTMLControl>,
  14. public IViewObjectExImpl<CTaskUI_HTMLControl>,
  15. public IOleInPlaceObjectWindowlessImpl<CTaskUI_HTMLControl>,
  16. public CComCoClass<CTaskUI_HTMLControl, &CLSID_TaskUI_HTMLControl>
  17. {
  18. public:
  19. CTaskUI_HTMLControl() : m_strURL(NULL)
  20. {
  21. m_bWindowOnly = TRUE;
  22. CWndClassInfo& wci = GetWndClassInfo();
  23. if (!wci.m_atom)
  24. {
  25. // Modify wndclass here if necessary
  26. wci.m_wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
  27. }
  28. }
  29. DECLARE_REGISTRY_RESOURCEID(IDR_TASKUI_HTMLCONTROL)
  30. DECLARE_PROTECT_FINAL_CONSTRUCT()
  31. BEGIN_COM_MAP(CTaskUI_HTMLControl)
  32. COM_INTERFACE_ENTRY(ITaskUI_HTMLControl)
  33. COM_INTERFACE_ENTRY2(IDispatch, ITaskUI_HTMLControl)
  34. COM_INTERFACE_ENTRY(IViewObjectEx)
  35. COM_INTERFACE_ENTRY(IViewObject2)
  36. COM_INTERFACE_ENTRY(IViewObject)
  37. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  38. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  39. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  40. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  41. COM_INTERFACE_ENTRY(IOleControl)
  42. COM_INTERFACE_ENTRY(IOleObject)
  43. END_COM_MAP()
  44. BEGIN_PROP_MAP(CTaskUI_HTMLControl)
  45. //PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  46. //PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  47. // Example entries
  48. // PROP_ENTRY("Property Description", dispid, clsid)
  49. // PROP_PAGE(CLSID_StockColorPage)
  50. END_PROP_MAP()
  51. BEGIN_MSG_MAP(CTaskUI_HTMLControl)
  52. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  53. CHAIN_MSG_MAP(CComControl<CTaskUI_HTMLControl>)
  54. END_MSG_MAP()
  55. // Handler prototypes:
  56. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  57. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  58. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  59. // IViewObjectEx
  60. DECLARE_VIEW_STATUS(0)
  61. // ITaskUI_HTMLControl
  62. public:
  63. STDMETHOD(Initialize)(/*[in]*/ BSTR strURL, /*[in, optional]*/ IDispatch* pExternalDispatch)
  64. {
  65. m_strURL = strURL;
  66. m_spExternalDispatch = pExternalDispatch;
  67. return S_OK;
  68. }
  69. // IOleObject overrides
  70. STDMETHOD(GetExtent)(DWORD /*dwDrawAspect*/, SIZEL *psizel)
  71. {
  72. if (psizel == NULL)
  73. return E_POINTER;
  74. psizel->cx = MAXLONG;
  75. psizel->cy = MAXLONG;
  76. return S_OK;
  77. }
  78. // Message handlers
  79. LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  80. {
  81. if (m_strURL)
  82. {
  83. CAxWindow wnd(m_hWnd);
  84. HRESULT hr = wnd.CreateControl(m_strURL);
  85. if (SUCCEEDED(hr) && m_spExternalDispatch)
  86. hr = wnd.SetExternalDispatch(m_spExternalDispatch);
  87. return SUCCEEDED(hr) ? 0 : -1;
  88. }
  89. return -1;
  90. }
  91. private:
  92. CComBSTR m_strURL;
  93. CComPtr<IDispatch> m_spExternalDispatch;
  94. };
  95. #endif //__TASKUI_HTMLCONTROL_H_