DocumentComplete Event.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can you teache me how to use this event as follows
I have no idea about this
There are not any example codes shown in MSDN on-line document

Thanks in advance
ps.Maybe navigatecomplete2 event can do the same thing, but
I still cannot figure out how to use this method too.


MSDN on-line document
DWebBrowserEvents2::DocumentComplete Even
Fires when a document has been completely loaded and initialized

Synta

void DocumentComplete( IDispatch* pDisp
VARIANT* UR
)
Parameter

pDis
[in] Pointer to the IDispatch interface of the window or frame in which the document has loaded. This IDispatch interface can be queried for the IWebBrowser2 interface.
UR
[in] Pointer to a VARIANT structure of type VT_BSTR that specifies the URL, Universal Naming Convention (UNC) file name, or pointer to an item identifier list (PIDL) of the loaded document.
Return Valu

No return value.
 
It is DHTML event, you can implement IDispatch interface and advise your
instance to the event.
// CComQIPtr<IWebBrowser2> m_spBrowser;
// CComQIPtr<IHTMLDocument2> m_spDocument;
// DWORD m_dwScrollSinkCookie;
// HRESULT m_hrScrollSink;
// LPCONNECTIONPOINT m_pScrollConnPoint;
void CXXX::InstallScrollEventSink(bool binstall)
{ //true: install scroll event sink to the HTMLWindow2 in the browser
control
//false:uninstall scroll event sink
HRESULT hr=-1;
m_hrScrollSink=-1;
if(m_spBrowser!=NULL)
{
hr=m_spBrowser->get_Document((IDispatch**)&m_spDocument);
}
if(SUCCEEDED(hr)&&m_spDocument!=NULL)
{
IHTMLWindow2* phtmlwnd2=NULL;
LPCONNECTIONPOINTCONTAINER pCPC = NULL;
hr=m_spDocument->get_parentWindow(&phtmlwnd2);
if(SUCCEEDED(hr)&&phtmlwnd2!=NULL)
{
hr = phtmlwnd2->QueryInterface(IID_IConnectionPointContainer,
(LPVOID*)&pCPC);
}
if(SUCCEEDED(hr)&&pCPC!=NULL)
{
hr= pCPC->FindConnectionPoint(DIID_HTMLWindowEvents,&m_pScrollConnPoint);
}
if(SUCCEEDED(hr))
{
if(binstall)

m_hrScrollSink=m_pScrollConnPoint->Advise(this->GetUnknown(),&m_dwScrollSink
Cookie);
else
{
m_hrScrollSink = -1;
m_pScrollConnPoint->Unadvise(m_dwScrollSinkCookie);
m_pScrollConnPoint->Release();
}
}
if(pCPC)
pCPC->Release();
if(phtmlwnd2!=NULL)
phtmlwnd2->Release();
}
}

STDMETHODIMP CXXX::Invoke(DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pvarResult,
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
if (!pDispParams)
return E_INVALIDARG;
switch (dispidMember)
{
case 0x3f6:
OnScrollEvent();//here is my event handler
break;
default:
//...
break;
}

return S_OK;
}

sam said:
Can you teache me how to use this event as follows.
I have no idea about this.
There are not any example codes shown in MSDN on-line document.

Thanks in advance.
ps.Maybe navigatecomplete2 event can do the same thing, but
I still cannot figure out how to use this method too.



MSDN on-line document.
DWebBrowserEvents2::DocumentComplete Event
Fires when a document has been completely loaded and initialized.

Syntax

void DocumentComplete( IDispatch* pDisp,
VARIANT* URL
);
Parameters

pDisp
[in] Pointer to the IDispatch interface of the window or frame in which
the document has loaded. This IDispatch interface can be queried for the
IWebBrowser2 interface.
URL
[in] Pointer to a VARIANT structure of type VT_BSTR that specifies the
URL, Universal Naming Convention (UNC) file name, or pointer to an item
identifier list (PIDL) of the loaded document.
 
Back
Top