DHTMLControl.h
上传用户:benben_wyd
上传日期:2010-02-26
资源大小:1229k
文件大小:4k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // DHTMLControl.h : Declaration of the CDHTMLControl
  2. #ifndef __DHTMLCONTROL_H_
  3. #define __DHTMLCONTROL_H_
  4. #include "resource.h"       // main symbols
  5. #include <atlctl.h>
  6. //Added by Chuck Wood for database support
  7. #include "lookup.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CDHTMLControl
  10. class ATL_NO_VTABLE CDHTMLControl : 
  11. public CComObjectRootEx<CComSingleThreadModel>,
  12. public IDispatchImpl<IDHTMLControl, &IID_IDHTMLControl, &LIBID_DHTMLGRADESLib>,
  13. public IDispatchImpl<IDHTMLControlUI, &IID_IDHTMLControlUI, &LIBID_DHTMLGRADESLib>,
  14. public CComControl<CDHTMLControl>,
  15. public IPersistStreamInitImpl<CDHTMLControl>,
  16. public IOleControlImpl<CDHTMLControl>,
  17. public IOleObjectImpl<CDHTMLControl>,
  18. public IOleInPlaceActiveObjectImpl<CDHTMLControl>,
  19. public IViewObjectExImpl<CDHTMLControl>,
  20. public IOleInPlaceObjectWindowlessImpl<CDHTMLControl>,
  21. public IPersistStorageImpl<CDHTMLControl>,
  22. public ISpecifyPropertyPagesImpl<CDHTMLControl>,
  23. public IQuickActivateImpl<CDHTMLControl>,
  24. public IDataObjectImpl<CDHTMLControl>,
  25. public IProvideClassInfo2Impl<&CLSID_DHTMLControl, NULL, &LIBID_DHTMLGRADESLib>,
  26. public CComCoClass<CDHTMLControl, &CLSID_DHTMLControl>
  27. {
  28. public:
  29. CDHTMLControl()
  30. {
  31. m_bWindowOnly = TRUE;
  32. }
  33. DECLARE_REGISTRY_RESOURCEID(IDR_DHTMLCONTROL)
  34. DECLARE_PROTECT_FINAL_CONSTRUCT()
  35. BEGIN_COM_MAP(CDHTMLControl)
  36. COM_INTERFACE_ENTRY(IDHTMLControl)
  37. COM_INTERFACE_ENTRY(IDHTMLControlUI)
  38. COM_INTERFACE_ENTRY2(IDispatch, IDHTMLControl)
  39. COM_INTERFACE_ENTRY(IViewObjectEx)
  40. COM_INTERFACE_ENTRY(IViewObject2)
  41. COM_INTERFACE_ENTRY(IViewObject)
  42. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  43. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  44. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  45. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  46. COM_INTERFACE_ENTRY(IOleControl)
  47. COM_INTERFACE_ENTRY(IOleObject)
  48. COM_INTERFACE_ENTRY(IPersistStreamInit)
  49. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  50. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  51. COM_INTERFACE_ENTRY(IQuickActivate)
  52. COM_INTERFACE_ENTRY(IPersistStorage)
  53. COM_INTERFACE_ENTRY(IDataObject)
  54. COM_INTERFACE_ENTRY(IProvideClassInfo)
  55. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  56. END_COM_MAP()
  57. BEGIN_PROP_MAP(CDHTMLControl)
  58. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  59. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  60. // Example entries
  61. // PROP_ENTRY("Property Description", dispid, clsid)
  62. // PROP_PAGE(CLSID_StockColorPage)
  63. END_PROP_MAP()
  64. BEGIN_MSG_MAP(CDHTMLControl)
  65. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  66. CHAIN_MSG_MAP(CComControl<CDHTMLControl>)
  67. END_MSG_MAP()
  68. // Handler prototypes:
  69. //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  70. //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  71. //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  72. // IViewObjectEx
  73. DECLARE_VIEW_STATUS(0)
  74. //fillGrades prototype Added by Chuck Wood 
  75. protected:
  76. void fillGrades(CComQIPtr<IHTMLFormElement> &spForm,
  77. CComQIPtr<IHTMLElement> &spTableElement);
  78. // IDHTMLControl
  79. public:
  80. // IDHTMLControlUI
  81. public:
  82. STDMETHOD(Lookup)(
  83. IDispatch* pdispForm, 
  84. IDispatch* pdispTable)
  85. {
  86. //Added by Chuck Wood
  87. CComQIPtr<IHTMLFormElement> spForm(pdispForm);
  88. CComQIPtr<IHTMLElement> spTableElement(pdispTable);
  89. if (!spForm || !spTableElement) {
  90. return E_FAIL;
  91. }
  92. else {
  93. fillGrades(spForm, spTableElement);
  94. }
  95. return S_OK;
  96. }
  97. LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  98. {
  99. CAxWindow wnd(m_hWnd);
  100. HRESULT hr = wnd.CreateControl(IDH_DHTMLCONTROL);
  101. if (SUCCEEDED(hr))
  102. hr = wnd.SetExternalDispatch(static_cast<IDHTMLControlUI*>(this));
  103. if (SUCCEEDED(hr))
  104. hr = wnd.QueryControl(IID_IWebBrowser2, (void**)&m_spBrowser);
  105. return SUCCEEDED(hr) ? 0 : -1;
  106. }
  107. CComPtr<IWebBrowser2> m_spBrowser;
  108. };
  109. #endif //__DHTMLCONTROL_H_