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.

162 lines
3.5 KiB

  1. /*
  2. */
  3. #pragma once
  4. #include "mshtml.h"
  5. #include "ihost.h"
  6. #include "SxApwComPtr.h"
  7. #include "atlwin.h"
  8. #include <vector>
  9. #include "FusionTrace.h"
  10. #include "iuiview.h"
  11. #include "SxApwWin.h"
  12. #include "mshtmdid.h"
  13. #include "comdef.h"
  14. #include "exdisp.h"
  15. extern _ATL_FUNC_INFO s_OnClickSignature;
  16. class __declspec(uuid(CLSID_CSxApwHost_declspec_uuid))
  17. CSxApwHost
  18. :
  19. public ATL::CComObjectRootEx<CComSingleThreadModel>,
  20. public ATL::CComCoClass<CSxApwHost, &__uuidof(CSxApwHost)>,
  21. public ISxApwHost,
  22. //public CSxApwHtmlEventSink
  23. public IDispatch
  24. //public ATL::IDispEventSimpleImpl<1, CSxApwHost, &DIID_HTMLElementEvents2>,
  25. //public ATL::IDispEventSimpleImpl<2, CSxApwHost, &DIID_HTMLElementEvents2>
  26. {
  27. public:
  28. //typedef ATL::IDispEventSimpleImpl<1, CSxApwHost, &DIID_HTMLElementEvents2> EventDisp1;
  29. //typedef ATL::IDispEventSimpleImpl<2, CSxApwHost, &DIID_HTMLElementEvents2> EventDisp2;
  30. CSxApwHost() { }
  31. BEGIN_COM_MAP(CSxApwHost)
  32. COM_INTERFACE_ENTRY(ISxApwHost)
  33. COM_INTERFACE_ENTRY(IDispatch)
  34. END_COM_MAP()
  35. DECLARE_NO_REGISTRY();
  36. void __stdcall F1()
  37. {
  38. printf("%s\n", __FUNCTION__);
  39. }
  40. void __stdcall F2()
  41. {
  42. printf("%s\n", __FUNCTION__);
  43. }
  44. STDMETHOD(Invoke)(
  45. DISPID dispId,
  46. REFIID riid,
  47. LCID lcid,
  48. WORD wFlags,
  49. DISPPARAMS* pDispParams,
  50. VARIANT* pVarResult,
  51. EXCEPINFO* pExcepInfo,
  52. UINT* puArgErr
  53. )
  54. {
  55. switch (dispId)
  56. {
  57. case 1:
  58. F1();
  59. break;
  60. case 2:
  61. F2();
  62. break;
  63. }
  64. return S_OK;
  65. }
  66. STDMETHOD(GetTypeInfoCount)(
  67. UINT* pcinto
  68. )
  69. {
  70. *pcinto = 0;
  71. return S_OK;
  72. }
  73. STDMETHOD(GetTypeInfo)(
  74. UINT iTInfo,
  75. LCID lcid,
  76. ITypeInfo** ppTInfo
  77. )
  78. {
  79. *ppTInfo = NULL;
  80. return E_NOTIMPL;
  81. }
  82. STDMETHOD(GetIDsOfNames)(
  83. REFIID iid,
  84. PWSTR* rgpszNames,
  85. UINT cNames,
  86. LCID lcid,
  87. DISPID* rgDispId
  88. )
  89. {
  90. //
  91. // Simple: find a run of decimal digits in each name, and convert it.
  92. //
  93. UINT i;
  94. for (i = 0 ; i != cNames ; ++i)
  95. {
  96. rgDispId[i] = _wtoi(rgpszNames[i] + wcscspn(rgpszNames[i], L"0123456789"));
  97. }
  98. return S_OK;
  99. }
  100. /*
  101. BEGIN_SINK_MAP(CSxApwHost)
  102. //SINK_ENTRY(1, DISPID_HTMLELEMENTEVENTS2_ONCLICK, OnClick1)
  103. //SINK_ENTRY(2, DISPID_HTMLELEMENTEVENTS2_ONCLICK, OnClick2)
  104. SINK_ENTRY_INFO(1, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS2_ONCLICK, F1, &s_OnClickSignature)
  105. SINK_ENTRY_INFO(2, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS2_ONCLICK, F2, &s_OnClickSignature)
  106. END_SINK_MAP()
  107. */
  108. STDMETHOD(SetDataSource)(
  109. LPCWSTR
  110. );
  111. STDMETHOD(CreateView)(
  112. LPCWSTR
  113. );
  114. STDMETHOD(DestroyView)(
  115. LPCWSTR
  116. ) { return S_OK; }
  117. STDMETHOD(RunQuery)(
  118. LPCWSTR
  119. );
  120. STDMETHOD(OnNextRow)(
  121. int nColumns,
  122. const LPCWSTR columns[]
  123. );
  124. STDMETHOD(OnRowCountEstimateAvailable)(
  125. int
  126. );
  127. STDMETHOD(OnQueryDone)(
  128. ) { return S_OK; }
  129. STDMETHOD(InformSchema)(
  130. const SxApwColumnInfo rgColumnInfo[],
  131. int nColumnCount
  132. );
  133. HRESULT Main();
  134. private:
  135. typedef std::vector<CSxApwComPtr<ISxApwUiView> > Views_t;
  136. Views_t m_views;
  137. CSxApwComPtr<ISxApwDataSource> m_dataSource;
  138. };