Add-On Hooking to Wrong IE Tab

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

Add-On Hooking to Wrong IE Tab
 
Mark Williams




Posts: 26
Joined: 2010-09-30
If I open up a bunch of tabs in Internet Explorer at one time I run into some problems.

Some instances of the add-on will hook to the wrong browser window. So tab 1 will in fact be hooked to tab 3.

So let's say in tab 1 I have http://www.google.com and sel ect the text "Alpha".

In tab 3 I have http://www.cnn.com open and select the text "Bravo".

I return to tab 1 and click on a button that runs the following code:

var q = (IHTMLTxtRange)this.HTMLDocument.selection.createRange();

var d = this.HTMLDocument.url.ToString();

MessageBox.Show(d + " - " + q.Text);

The result will be "http://www.cnn.com - Bravo" when it should be "http://www.google.com - Alpha". The add-on in the first tab is getting everything fr om the third tab.

Any idea what I can do to prevent this? This is a major bug that I need to fix pretty soon.
Posted 28 Jan, 2011 13:11:13 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Mark.

What the button do you mean? Is it a button added to the Commands collection of iemodule?
Posted 31 Jan, 2011 08:26:57 Top
Mark Williams




Posts: 26
Joined: 2010-09-30
It's a button in the toolbar.

Like

LinkButton_Click(object sender, EventArgs e)
{
var q = (IHTMLTxtRange)this.HTMLDocument.selection.createRange();

var d = this.HTMLDocument.url.ToString();

MessageBox.Show(d + " - " + q.Text);
}

IEObj returns the wrong browser window.
Posted 31 Jan, 2011 10:28:53 Top
Mark Williams




Posts: 26
Joined: 2010-09-30
This only happens when multiple links are opened OUTSIDE of Internet Explorer.

To reproduce:
1. Create a new add-on with a toolbar.

Add a LinkButton to the toolbar with the following click event:

LinkButton1_Click(object sender, EventArgs e)
{
var q = (IHTMLTxtRange)this.HTMLDocument.selection.createRange();

var d = this.HTMLDocument.url.ToString();

MessageBox.Show(d + " - " + q.Text);
}

Using an external email program (like Microsoft Outlook) send yourself an email with several links, say like this:
http://news.bbc.co.uk
http://www.google.com
http://www.nytimes.com
http://www.washingtonpost.com
http://www.drudgereport.com

Click all the links, one after another, inside your email program. Do this quickly.

Now select text in the various tabs and click the LinkButton you created. See if you are getting expected results. You should see behavior like the one described in my first post.

Tracing back
HTMLDocument <- HTMLDocumentObj <- IEObj <- ieObj

ieObj seems to be hooked into the browser at IObjectWithSite.SetSite. ieObj is getting assigned to the wrong browser tab.
Posted 31 Jan, 2011 12:53:40 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Mark, SetSite always returns the correct BandObjectSite. I will test this scenario and let you know about results soon.
Posted 31 Jan, 2011 13:47:29 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Mark.

I didn't manage to reproduce the issue.
Is it reproducible if you set several web pages as Home page in Internet Explorer options?
Posted 01 Feb, 2011 08:53:53 Top
Mark Williams




Posts: 26
Joined: 2010-09-30
No. The pages have to be opened from outside IE. Maybe there is a problem with my code.

Either way, is there a way to re-hook ieObj? If you have code that can do that or you have a method in the source I can call that would solve my problems.
Posted 01 Feb, 2011 10:42:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Mark.

There is not any way to reload an add-on in the same tab. You can send me the code for testing if you wish.
Posted 01 Feb, 2011 11:41:09 Top