Hi can anybody help me.
I am trying to hook into HTMLDocumentEvents2_Events on a mshtml web browser
hosted in a windows form with the designMode turned on in the document. When
I don't hook into the events I am able to write inside the document but when
I hook into any event then when ever I type on the keyboard nothing gets
reflected back to the html document.
If someone has an answer to this problem. I would very gratefull for their
assistance
Thanks in advance
Hiren
Hi Hiren
This is caused by one of the (several) bugs in the WebBrowser control. The
solution follows. You will have to create your own class, as shown, that
implements the HTMLDocumentEvents2 interface. If you do this in VB.NET V2003
then the IDE will insert all the necessary methods for you.
Use the function below to hook the interface in the WebBrowser control. Make
sure you call this after you have initialised the control as it requires a
valid document to work. In the DocumentComplete event is a good place.
<code>
Private m_DocEvents2Cookie As Integer = -1
Private Sub EnableDocEvents()
Dim icp As UCOMIConnectionPoint
Dim icpc As UCOMIConnectionPointContainer
Dim g As Guid
g = GetType(mshtml.HTMLDocumentEvents2).GUID
icpc = DirectCast(AxWebBrowser1.Document, UCOMIConnectionPointContainer)
icpc.FindConnectionPoint(g, icp)
If m_DocEvents2Cookie <> -1 Then
icp.Unadvise(m_DocEvents2Cookie)
m_DocEvents2Cookie = -1
End If
icp.Advise(New DocumentEvents2, m_DocEvents2Cookie)
' Wait until the browser has settled before returning
Do Until AxWebBrowser1.ReadyState =
SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
End Sub
Public Class DocumentEvents2
Implements mshtml.HTMLDocumentEvents2
' Implement each required sub and function
' Make sure to return True from every function by default
...
End Class
</code>
You can then write your own event handling code in the new class.
HTH
Charles
> Hi can anybody help me.
>
[quoted text clipped - 10 lines]
>
> Hiren