Back to index

lightning-sunbird  0.9+nobinonly
ControlEventSink.cpp
Go to the documentation of this file.
00001 // ControlEventSink.cpp : Implementation of CBrowseEventSink
00002 #include "stdafx.h"
00003 #include "Cbrowse.h"
00004 #include "ControlEventSink.h"
00005 
00007 // CBrowseEventSink
00008 
00009 HRESULT STDMETHODCALLTYPE CBrowseEventSink::GetTypeInfoCount( 
00010     /* [out] */ UINT __RPC_FAR *pctinfo)
00011 {
00012     return E_NOTIMPL;
00013 }
00014 
00015 HRESULT STDMETHODCALLTYPE CBrowseEventSink::GetTypeInfo( 
00016     /* [in] */ UINT iTInfo,
00017     /* [in] */ LCID lcid,
00018     /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
00019 {
00020     return E_NOTIMPL;
00021 }
00022 
00023 HRESULT STDMETHODCALLTYPE CBrowseEventSink::GetIDsOfNames( 
00024     /* [in] */ REFIID riid,
00025     /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
00026     /* [in] */ UINT cNames,
00027     /* [in] */ LCID lcid,
00028     /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
00029 {
00030     return E_NOTIMPL;
00031 }
00032 
00033 HRESULT STDMETHODCALLTYPE CBrowseEventSink:: Invoke( 
00034     /* [in] */ DISPID dispIdMember,
00035     /* [in] */ REFIID riid,
00036     /* [in] */ LCID lcid,
00037     /* [in] */ WORD wFlags,
00038     /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
00039     /* [out] */ VARIANT __RPC_FAR *pVarResult,
00040     /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
00041     /* [out] */ UINT __RPC_FAR *puArgErr)
00042 {
00043     CString szEvent;
00044 
00045     switch (dispIdMember)
00046     {
00047     case 0x66:
00048         {
00049             USES_CONVERSION;
00050             CString szText(OLE2T(pDispParams->rgvarg[0].bstrVal));
00051             szEvent.Format(_T("StatusTextChange: \"%s\""), szText);
00052             m_pBrowseDlg->m_TabMessages.m_szStatus = szText;
00053             m_pBrowseDlg->m_TabMessages.UpdateData(FALSE);
00054         }
00055         break;
00056     case 0x6c:
00057         {
00058             LONG nProgress = pDispParams->rgvarg[1].lVal;
00059             LONG nProgressMax = pDispParams->rgvarg[0].lVal;
00060             szEvent.Format("ProgressChange(%d of %d)", nProgress, nProgressMax);
00061             CProgressCtrl &pc = m_pBrowseDlg->m_TabMessages.m_pcProgress;
00062             pc.SetRange(0, nProgressMax);
00063             pc.SetPos(nProgress);
00064         }
00065         break;
00066     case 0x69:
00067         {
00068             BOOL enable = pDispParams->rgvarg[0].boolVal == VARIANT_TRUE ? TRUE : FALSE;
00069             LONG commandState = pDispParams->rgvarg[1].lVal;
00070             if (commandState == CSC_NAVIGATEBACK)
00071             {
00072                 m_pBrowseDlg->m_bCanGoBack = enable;
00073                 m_pBrowseDlg->m_btnBack.EnableWindow(enable);
00074             }
00075             else if (commandState == CSC_NAVIGATEFORWARD)
00076             {
00077                 m_pBrowseDlg->m_bCanGoForward = enable;
00078                 m_pBrowseDlg->m_btnForward.EnableWindow(enable);
00079             }
00080             szEvent.Format(_T("CommandStateChange(%ld, %d)"), commandState, enable);
00081         }
00082         break;
00083     case 0x6a:
00084         szEvent = _T("DownloadBegin");
00085         m_pBrowseDlg->m_btnStop.EnableWindow(TRUE);
00086         break;
00087     case 0x68:
00088         szEvent = _T("DownloadComplete");
00089         m_pBrowseDlg->m_btnStop.EnableWindow(FALSE);
00090         break;
00091     case 0x71:
00092         {
00093             USES_CONVERSION;
00094             CString szText(OLE2T(pDispParams->rgvarg[0].bstrVal));
00095             szEvent.Format(_T("TitleChange: \"%s\""), szText);
00096             CString szTitle;
00097             szTitle.Format(_T("CBrowse - %s"), szText);
00098             m_pBrowseDlg->SetWindowText(szTitle);
00099         }
00100         break;
00101     case 0x70:
00102         szEvent = _T("PropertyChange");
00103         break;
00104     case 0xfa:
00105         szEvent = _T("BeforeNavigate2");
00106         break;
00107     case 0xfb:
00108         {
00109             szEvent = _T("NewWindow2");
00110             
00111             VARIANTARG *pvars = pDispParams->rgvarg;
00112             CBrowseDlg *pDlg = new CBrowseDlg;
00113             if (pDlg)
00114             {
00115                 pDlg->m_clsid = m_pBrowseDlg->m_clsid;
00116                 pDlg->Create(IDD_CBROWSE_DIALOG);
00117                 
00118                 if (pDlg->m_pControlSite)
00119                 {
00120                     CIUnkPtr spUnkBrowser;
00121                     pDlg->m_pControlSite->GetControlUnknown(&spUnkBrowser);
00122 
00123                     pvars[0].byref = (void *) VARIANT_FALSE;
00124                     spUnkBrowser->QueryInterface(IID_IDispatch, (void **) pvars[1].byref);
00125                 }
00126             }
00127         }
00128         break;
00129     case 0xfc:
00130         szEvent = _T("NavigateComplete2");
00131         break;
00132     case 0x103:
00133         szEvent = _T("DocumentComplete");
00134         if (m_pBrowseDlg)
00135         {
00136             m_pBrowseDlg->UpdateURL();
00137         }
00138         break;
00139     case 0xfd:
00140         szEvent = _T("OnQuit");
00141         break;
00142     case 0xfe:
00143         szEvent = _T("OnVisible");
00144         break;
00145     case 0xff:
00146         szEvent = _T("OnToolBar");
00147         break;
00148     case 0x100:
00149         szEvent = _T("OnMenuBar");
00150         break;
00151     case 0x101:
00152         szEvent = _T("OnStatusBar");
00153         break;
00154     case 0x102:
00155         szEvent = _T("OnFullScreen");
00156         break;
00157     case 0x104:
00158         szEvent = _T("OnTheaterMode");
00159         break;
00160     default:
00161         szEvent.Format(_T("%d"), dispIdMember);
00162     }
00163 
00164     if (m_pBrowseDlg)
00165     {
00166         m_pBrowseDlg->OutputString(_T("Event %s"), szEvent);
00167     }
00168     return S_OK;
00169 }