Open a Popup

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

Open a Popup
 
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Is there a way to open a popup after clicking a Toolstripbutton?

HTMLDocument.parentWindow.open() get's blocked by the browser because it gets executed not from a link. :(
Posted 25 Jul, 2011 07:46:46 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Ronald,

Do you need to open a new browser window?
Posted 25 Jul, 2011 10:21:11 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Hi Sergey,

Yes, in a popup fashion.
Posted 25 Jul, 2011 13:25:50 Top
Itra Itra




Posts: 4
Joined: 2011-05-16
Hi!
I we need to show a popup in IE 7 (not as modal dialog). When user clicks a button on our plugin a popup window (with active focus) must be opened, with opened page from a specific url. I tried the following approaches:
1. Usage of Interop.SHDocVw.InternetExplorer class. It shows a window, but the problem is that this window is not focused. I tried to use WinAPI functions to set focus on it, but it doesn't work.
2. Usage of the property public IE.WebBrowser IEApp from the module and it's method Navigate2(url) [IEApp.Navigate()]. I stored the reference to the IEApp instance in a static field of the static class. The 'url' parameter contains javascript which opens the window. It opens the window first time, but second time reference to IEApp is null, so I'm getting NullReferenceException. Here is the format string for jav * ascript: jav * ascript:void(window.open('{0}','{1}','left={2},top={3},width={4},height={5},resizable=no,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no'.
OS: WinXP, IE 7.

Best regards from Minsk.
Posted 27 Jul, 2011 05:56:34 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Itra.

It seems that you just don't quite understand the IE architecture. It is not possible to create a new window and store a reference to the new IE instance in the source code. The fact is that IE creates a new instance of the add-on for each window/tab.
Posted 27 Jul, 2011 07:00:56 Top
Itra Itra




Posts: 4
Joined: 2011-05-16
Thanks a lot.
Posted 27 Jul, 2011 07:32:40 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Ronald,

What the parameters do you use in the open method?
Posted 27 Jul, 2011 07:36:13 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Hi Sergey, in my first post above you'll see this:

HTMLDocument.parentWindow.open() get's blocked by the browser because it gets executed not from a link.


That's it.
Posted 27 Jul, 2011 09:06:00 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Ronald, please try to use the code below:

enum BrowserNavConstants
{
navOpenInNewWindow = 1,
navNoHistory = 2,
navNoReadFromCache = 4,
navNoWriteToCache = 8,
navAllowAutosearch = 16,
navBrowserBar = 32,
navHyperlink = 64,
navEnforceRestricted = 128,
navNewWindowsManaged = 256,
navUntrustedForDownload = 512,
navTrustedForActiveX = 1024,
navOpenInNewTab = 2048,
navOpenInBackgroundTab = 4096,
navKeepWordWheelText = 8192,
navVirtualTab = 16384,
navBlockRedirectsXDomain = 32768,
navOpenNewForegroundTab = 65536
}

private void adxieContextMenuCommandItem1_OnClick(object sender, object htmlElement)
{

object dummy = null;
object flags = BrowserNavConstants.navOpenInNewWindow;
object url = "about:blank";

if (this.IEVersion < 9)
IEApp.Navigate2(ref url, ref flags, ref dummy, ref dummy, ref dummy);
else
System.Diagnostics.Process.Start("about:blank");
}
Posted 27 Jul, 2011 09:28:42 Top
Ronald Abegg




Posts: 21
Joined: 2011-03-25
Thank you Sergey, this is where we aiming to. Though, this opens a plain new browser window. We'd like to open it more like a popup, with a specific window size, without toolbars, etc. Just Like the javascript .open() function does.
Posted 27 Jul, 2011 10:03:35 Top