ADXIEHTMLDocEvents component events called multiple times.

Add-in Express™ Support Service
That's what is more important than anything else

ADXIEHTMLDocEvents component events called multiple times.
 
ravinukala




Posts: 103
Joined: 2012-10-05
Hi.

I am using 'ADXIEHTMLDocEvents' component to intercept left/right click.
I can see the event is being called multiple times for single click.

Can you please why it so?

How can I avoid it?

Thanks.
Posted 11 Oct, 2012 06:50:59 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

What the value is set in the 'SupportedEvents' property of the 'ADXIEHTMLDocEvents' component?
Posted 11 Oct, 2012 08:05:27 Top
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

I have set value for 'SupportedEvents' property to all type of html elements because I want get information about all html elements.


Thanks.
Posted 12 Oct, 2012 04:08:03 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

That is why you get multiple events. To obtain the information about the source of the event you can use the 'eventObject' argument of the event handler (you need t cast it to mshtml.IHTMLEventObj2).
Posted 12 Oct, 2012 05:40:22 Top
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

I have already converted 'eventObject' to mshtml.IHTMLEventObj2.

Problem is event is being called multiple times for single mshtml.IHTMLEventObj2 for single click.

Thanks.
Posted 12 Oct, 2012 07:53:37 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Rave, please use the 'srcElement' property of the IHTMLEventObj2 interface to get the source element.
You can also use the following code to obtain the HTML element:

private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, ADXCancelEventArgs e)
{
int x = ((mshtml.IHTMLEventObj2) eventObject).x;
int y = ((mshtml.IHTMLEventObj2) eventObject).y;
mshtml.IHTMLElement2 elem =
ADXIEHelper.GetHTMLElementByPoint(this.HTMLDocument, x, y) as mshtml.IHTMLElement2;
if (elem != null)
{
}
}
Posted 12 Oct, 2012 08:47:46 Top
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

Here is my code :

private void adxiehtmlDocEvents1_OnContextMenu(object sender, object eventObject, ADXCancelEventArgs e)
{
mshtml.IHTMLEventObj2 eventObj = (mshtml.IHTMLEventObj2)eventObject;
mshtml.IHTMLElement element = eventObj.srcElement;

if (element != null)
{
MessageBox.Show(element.GetType().ToS tring());
}
}

I am trying this on "http://www.google.com/"

When I right click in search box, I get the message box 18 times.

When I right click on Google image, I get the message box 8 times.

Every time I am getting same message.

I doubt this event calling for all its parent in DOM structure.

Please help.

Thanks.
Posted 18 Oct, 2012 03:05:03 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

When you connect to several HTML elements, IE returns the top object which has been clicked.
You can use the 'parentElement' property to get the parent HTML element(s). E.g. you can connect to HTML document only and use 'parentElement' to pass through all HTML element in the current hierarchy.
Posted 18 Oct, 2012 04:33:05 Top