1
0

evntsink.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /**************************************************************************
  2. THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright 1998 Microsoft Corporation. All Rights Reserved.
  7. **************************************************************************/
  8. /**************************************************************************
  9. File: evntsink.cpp
  10. Description: This file contains the implementation of the event sink.
  11. **************************************************************************/
  12. /**************************************************************************
  13. #include statements
  14. **************************************************************************/
  15. #include "main.h"
  16. #include <windows.h>
  17. #include "evntsink.h"
  18. /**************************************************************************
  19. function prototypes
  20. **************************************************************************/
  21. /**************************************************************************
  22. global variables and definitions
  23. **************************************************************************/
  24. /**************************************************************************
  25. CEventSink::CEventSink()
  26. **************************************************************************/
  27. CEventSink::CEventSink()
  28. {
  29. m_cRefs = 1;
  30. }
  31. /**************************************************************************
  32. CEventSink::QueryInterface()
  33. **************************************************************************/
  34. STDMETHODIMP CEventSink::QueryInterface(REFIID riid, PVOID *ppvObject)
  35. {
  36. if (!ppvObject)
  37. return E_POINTER;
  38. if (IsEqualIID(riid, IID_IDispatch))
  39. *ppvObject = (IDispatch *)this;
  40. else if (IsEqualIID(riid, IID_IUnknown))
  41. *ppvObject = this;
  42. else
  43. {
  44. *ppvObject = NULL;
  45. return E_NOINTERFACE;
  46. }
  47. AddRef();
  48. return S_OK;
  49. }
  50. /**************************************************************************
  51. CEventSink::AddRef()
  52. **************************************************************************/
  53. ULONG CEventSink::AddRef(void)
  54. {
  55. return ++m_cRefs;
  56. }
  57. /**************************************************************************
  58. CEventSink::Release()
  59. **************************************************************************/
  60. ULONG CEventSink::Release(void)
  61. {
  62. if (--m_cRefs)
  63. return m_cRefs;
  64. delete this;
  65. return 0;
  66. }
  67. /**************************************************************************
  68. CEventSink::GetIDsOfNames()
  69. **************************************************************************/
  70. HRESULT CEventSink::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
  71. {
  72. *rgdispid = DISPID_UNKNOWN;
  73. return DISP_E_UNKNOWNNAME;
  74. }
  75. /**************************************************************************
  76. CEventSink::GetTypeInfo()
  77. **************************************************************************/
  78. HRESULT CEventSink::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
  79. {
  80. return E_NOTIMPL;
  81. }
  82. /**************************************************************************
  83. CEventSink::GetTypeInfoCount()
  84. **************************************************************************/
  85. HRESULT CEventSink::GetTypeInfoCount(unsigned int FAR * pctinfo)
  86. {
  87. return E_NOTIMPL;
  88. }
  89. /**************************************************************************
  90. CEventSink::Invoke()
  91. **************************************************************************/
  92. void main_setStatusText(LPCWSTR txt)
  93. {
  94. char dest[512];
  95. dest[0]=0;
  96. WideCharToMultiByte(CP_ACP,0,txt,-1,dest,sizeof(dest),NULL,NULL);
  97. //SetDlgItemText(m_hwnd,IDC_STATUS,dest);
  98. }
  99. void main_beforeNavigate(LPCWSTR txt)
  100. {
  101. VARIANT *blah=(VARIANT *)txt;
  102. char dest[512];
  103. dest[0]=0;
  104. WideCharToMultiByte(CP_ACP,0,blah->bstrVal,-1,dest,sizeof(dest),NULL,NULL);
  105. //SetDlgItemText(m_hwnd,IDC_QUICKSEARCH,dest);
  106. }
  107. HRESULT CEventSink::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  108. {
  109. switch (dispid)
  110. {
  111. // void StatusTextChange([in] BSTR Text);
  112. case 0x66:
  113. main_setStatusText(pdispparams->rgvarg[0].bstrVal);
  114. //m_pApp->eventStatusTextChange(pdispparams->rgvarg[0].bstrVal);
  115. break;
  116. // void ProgressChange([in] long Progress, [in] long ProgressMax);
  117. case 0x6c:
  118. break;
  119. // void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable);
  120. case 0x69:
  121. //m_pApp->eventCommandStateChange(pdispparams->rgvarg[1].lVal, pdispparams->rgvarg[0].boolVal);
  122. break;
  123. // void DownloadBegin();
  124. case 0x6a:
  125. //m_pApp->eventDownloadBegin();
  126. break;
  127. // void DownloadComplete();
  128. case 0x68:
  129. //m_pApp->eventDownloadComplete();
  130. break;
  131. // void TitleChange([in] BSTR Text);
  132. case 0x071:
  133. //m_pApp->eventTitleChange(pdispparams->rgvarg[0].bstrVal);
  134. break;
  135. // void PropertyChange([in] BSTR szProperty);
  136. case 0x70:
  137. //m_pApp->eventPropertyChange(pdispparams->rgvarg[0].bstrVal);
  138. break;
  139. // void BeforeNavigate2([in] IDispatch* pDisp, [in] VARIANT* URL, [in] VARIANT* Flags, [in] VARIANT* TargetFrameName, [in] VARIANT* PostData, [in] VARIANT* Headers, [in, out] VARIANT_BOOL* Cancel);
  140. case 0xfa:
  141. main_beforeNavigate(pdispparams->rgvarg[5].bstrVal);
  142. break;
  143. // void NewWindow2([in, out] IDispatch** ppDisp, [in, out] VARIANT_BOOL* Cancel);
  144. case 0xfb:
  145. break;
  146. // void NavigateComplete2([in] IDispatch* pDisp, [in] VARIANT* URL);
  147. case 0xfc:
  148. break;
  149. // void DocumentComplete([in] IDispatch* pDisp, [in] VARIANT* URL);
  150. case 0x0103:
  151. break;
  152. // void OnQuit();
  153. case 0xfd:
  154. break;
  155. // void OnVisible([in] VARIANT_BOOL Visible);
  156. case 0xfe:
  157. break;
  158. // void OnToolBar([in] VARIANT_BOOL ToolBar);
  159. case 0xff:
  160. break;
  161. // void OnMenuBar([in] VARIANT_BOOL MenuBar);
  162. case 0x0100:
  163. break;
  164. // void OnStatusBar([in] VARIANT_BOOL StatusBar);
  165. case 0x0101:
  166. break;
  167. // void OnFullScreen([in] VARIANT_BOOL FullScreen);
  168. case 0x0102:
  169. break;
  170. // void OnTheaterMode([in] VARIANT_BOOL TheaterMode);
  171. case 0x0104:
  172. break;
  173. }
  174. return S_OK;
  175. }