The .Net 2.0's webbrowser control is neat and pretty.
But I am not able to capture Key events when the focus is on the
webbrowser control in my winform.
Options tried.
1. Wrote a class which extends this WebBrowser and override its onkeyup
event - didn't work.
2. Same as option 1 but override preprocessmessage - didn't work.
3. Same as option 1 but override WndProc - doesn't capture any key
events happening in the browser.
Nothing works.
Can someone help me here. Would be gr8 if u can solve this.
Thanks in advance,
Vin
Hi Vin
The V2.0 WebBrowser control is the same old mshtml / shdocvw under the
covers, so I think you will have to do it the age old way. In the
DocumentComplete event, do the following
<snip>
Private m_DocEvents2Cookie As Integer = -1 ' make this a member
variable
...
Dim icp As ComTypes.IConnectionPoint = Nothing
Dim icpc As ComTypes.IConnectionPointContainer
Dim g As Guid
g = GetType(mshtml.HTMLDocumentEvents2).GUID
icpc = DirectCast(WebBrowser1.Document.DomDocument,
ComTypes.IConnectionPointContainer)
icpc.FindConnectionPoint(g, icp)
If m_DocEvents2Cookie <> -1 Then
icp.Unadvise(m_DocEvents2Cookie)
m_DocEvents2Cookie = -1
End If
icp.Advise(New DocumentEvents2, m_DocEvents2Cookie)
</snip>
where DocumentEvents2 is a class that you create that implements
mshtml.HTMLDocumentEvents2. The onkeyup event in your class will then fire.
HTH
Charles
> The .Net 2.0's webbrowser control is neat and pretty.
> But I am not able to capture Key events when the focus is on the
[quoted text clipped - 12 lines]
> Thanks in advance,
> Vin