123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- /**************************************************************************
- THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
- ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- PARTICULAR PURPOSE.
- Copyright 1998 Microsoft Corporation. All Rights Reserved.
- **************************************************************************/
- /**************************************************************************
- File: evntsink.cpp
- Description: This file contains the implementation of the event sink.
- **************************************************************************/
- /**************************************************************************
- #include statements
- **************************************************************************/
- #include "main.h"
- #include <windows.h>
- #include "evntsink.h"
- /**************************************************************************
- function prototypes
- **************************************************************************/
- /**************************************************************************
- global variables and definitions
- **************************************************************************/
- /**************************************************************************
- CEventSink::CEventSink()
- **************************************************************************/
- CEventSink::CEventSink()
- {
- m_cRefs = 1;
- }
- /**************************************************************************
- CEventSink::QueryInterface()
- **************************************************************************/
- STDMETHODIMP CEventSink::QueryInterface(REFIID riid, PVOID *ppvObject)
- {
- if (!ppvObject)
- return E_POINTER;
- if (IsEqualIID(riid, IID_IDispatch))
- *ppvObject = (IDispatch *)this;
- else if (IsEqualIID(riid, IID_IUnknown))
- *ppvObject = this;
- else
- {
- *ppvObject = NULL;
- return E_NOINTERFACE;
- }
- AddRef();
- return S_OK;
- }
- /**************************************************************************
- CEventSink::AddRef()
- **************************************************************************/
- ULONG CEventSink::AddRef(void)
- {
- return ++m_cRefs;
- }
- /**************************************************************************
- CEventSink::Release()
- **************************************************************************/
- ULONG CEventSink::Release(void)
- {
- if (--m_cRefs)
- return m_cRefs;
- delete this;
- return 0;
- }
- /**************************************************************************
- CEventSink::GetIDsOfNames()
- **************************************************************************/
- HRESULT CEventSink::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
- {
- *rgdispid = DISPID_UNKNOWN;
- return DISP_E_UNKNOWNNAME;
- }
- /**************************************************************************
- CEventSink::GetTypeInfo()
- **************************************************************************/
- HRESULT CEventSink::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
- {
- return E_NOTIMPL;
- }
- /**************************************************************************
- CEventSink::GetTypeInfoCount()
- **************************************************************************/
- HRESULT CEventSink::GetTypeInfoCount(unsigned int FAR * pctinfo)
- {
- return E_NOTIMPL;
- }
- /**************************************************************************
- CEventSink::Invoke()
- **************************************************************************/
- void main_setStatusText(LPCWSTR txt)
- {
- char dest[512];
- dest[0]=0;
- WideCharToMultiByte(CP_ACP,0,txt,-1,dest,sizeof(dest),NULL,NULL);
- //SetDlgItemText(m_hwnd,IDC_STATUS,dest);
- }
- void main_beforeNavigate(LPCWSTR txt)
- {
- VARIANT *blah=(VARIANT *)txt;
- char dest[512];
- dest[0]=0;
- WideCharToMultiByte(CP_ACP,0,blah->bstrVal,-1,dest,sizeof(dest),NULL,NULL);
- //SetDlgItemText(m_hwnd,IDC_QUICKSEARCH,dest);
- }
- HRESULT CEventSink::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
- {
- switch (dispid)
- {
- // void StatusTextChange([in] BSTR Text);
- case 0x66:
- main_setStatusText(pdispparams->rgvarg[0].bstrVal);
- //m_pApp->eventStatusTextChange(pdispparams->rgvarg[0].bstrVal);
- break;
- // void ProgressChange([in] long Progress, [in] long ProgressMax);
- case 0x6c:
- break;
- // void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable);
- case 0x69:
- //m_pApp->eventCommandStateChange(pdispparams->rgvarg[1].lVal, pdispparams->rgvarg[0].boolVal);
- break;
- // void DownloadBegin();
- case 0x6a:
- //m_pApp->eventDownloadBegin();
- break;
- // void DownloadComplete();
- case 0x68:
- //m_pApp->eventDownloadComplete();
- break;
-
- // void TitleChange([in] BSTR Text);
- case 0x071:
- //m_pApp->eventTitleChange(pdispparams->rgvarg[0].bstrVal);
- break;
- // void PropertyChange([in] BSTR szProperty);
- case 0x70:
- //m_pApp->eventPropertyChange(pdispparams->rgvarg[0].bstrVal);
- break;
- // 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);
- case 0xfa:
- main_beforeNavigate(pdispparams->rgvarg[5].bstrVal);
- break;
- // void NewWindow2([in, out] IDispatch** ppDisp, [in, out] VARIANT_BOOL* Cancel);
- case 0xfb:
- break;
-
- // void NavigateComplete2([in] IDispatch* pDisp, [in] VARIANT* URL);
- case 0xfc:
- break;
- // void DocumentComplete([in] IDispatch* pDisp, [in] VARIANT* URL);
- case 0x0103:
- break;
- // void OnQuit();
- case 0xfd:
- break;
- // void OnVisible([in] VARIANT_BOOL Visible);
- case 0xfe:
- break;
- // void OnToolBar([in] VARIANT_BOOL ToolBar);
- case 0xff:
- break;
- // void OnMenuBar([in] VARIANT_BOOL MenuBar);
- case 0x0100:
- break;
- // void OnStatusBar([in] VARIANT_BOOL StatusBar);
- case 0x0101:
- break;
-
- // void OnFullScreen([in] VARIANT_BOOL FullScreen);
- case 0x0102:
- break;
-
- // void OnTheaterMode([in] VARIANT_BOOL TheaterMode);
- case 0x0104:
- break;
- }
- return S_OK;
- }
|