IHTMLDocument2 onclick event

  • Thread starter Thread starter Chris Soulsby
  • Start date Start date
C

Chris Soulsby

Hi,

I have a control that contains a embedded ie control. I used the following
code to add a onclick event to a table element:

IHTMLDocument2 oIHTMLDocument2 =
(IHTMLDocument2)m_oWebBrowserControl.Document;
mshtml.HTMLTableClass oHTMLElement =
(mshtml.HTMLTableClass)oIHTMLDocument2.all.item(strObjectName, null);
((mshtml.HTMLTableEvents2_Event)oHTMLElement).onclick += oEventHandler;

This code works fine, however, sometimes it seems to stop working and I
don't receive any more onclick events. This seems to be a random.

Has anyone come across this problem, do you how to get solve it?

Thanks

Chris
 
While I still can't work out why it stops working, I have discovered that if
you add the onclick event to
the document instead of a table it will always work. You can then check to
see if the the table is the element to be clicked when you receive the
event.

I used the following code:

IHTMLDocument2 oIHTMLDocument2 =
(IHTMLDocument2)m_oWebBrowserControl.Document;
((mshtml.HTMLDocumentEvents2_Event)oIHTMLDocument2).onclick +=
oEventHandler;

Thanks

Chris
 
Back
Top