Nitin Mankar

Hi,

We have windows application, where we have provided menus to open the web pages from the web application without login to the web application. All the menu items in the windows application opens web pages from the same web application.


With IE6, when I open say directory page then it opens the page in a new window. Now keeping the IE 6 open and I click on Profile menu item in windows application then it opens the page in same IE6 window.
However, with IE7 when I click on Directory menu it opens the page in new window and then if I click on Profile menu item then it opens the page in new window.

I am using following code to open web page from windows application

System.Diagnostics.Process.Start(webSiteName + "/login.aspx ");

System.Diagnostics.Process.Start(webSiteName + "/" + reportname + ".aspx");


I know by changing the Internet options setting I can disable tabs in IE7.
The customer does not want this setting to be changed.
IS there any way to open the web page in same tab from the C# application.

Thanks in advance.

Regards,
Nitin Mankar



Re: Internet Explorer Extension Development Opening web page from Windows application opens in new tab

John Sudds - MSFT

Disclaimer: I haven't tried this, but it looks like it nicely addresses your issue.
Source: http://west-wind.com/weblog/posts/2050.aspx

There are a couple of other ways you can use IE if you don't care about the appearance of the Window. The ShellExecute API is the easiest and you can use System.Runtime.Process.Start(). This method has the unfriendly side effect of always firing up a new window for each navigation - usually that's not what I want. You can also use ShellExecute using PInvoke:

[DllImport("Shell32.dll")]

private static extern int ShellExecute(int hwnd, string lpOperation,

string lpFile, string lpParameters,

string lpDirectory, int nShowCmd);

public static int GoUrl(string lcUrl)

{

string lcTPath = Path.GetTempPath();

int lnResult = ShellExecute(0,"OPEN",lcUrl, "",lcTPath,1);

return lnResult;

}

which lets you easily preview any type of document that Windows supports. Unlike Process.Run() it reuses the same window for URLs. This works but you have no control over the IE window that pops up because there¡¯s no link between your app and the window.






Re: Internet Explorer Extension Development Opening web page from Windows application opens in new tab

brianpmccullough

Hello Nitin,

I was doing some searching to find a resolution to an issue I am having with calling System.Diagnostics.Process.Start() from my WinForms application to display a url in IE. I, too, am experiencing the same issue as you described in your post in which IE6 reuses the existing window and IE7 resuses the existing window, but opens a new tab.

Did you ever come up with a solution that resolved this problem for you (either coding or IE configuration)

Thanks!!!

-Brian McCullough






Re: Internet Explorer Extension Development Opening web page from Windows application opens in new tab

John Sudds - MSFT

IE6 is much different than IE7 with regards to how it handles new windows. To make matters worse, IE7 itself behaves differently on Windows XP than it does on Windows Vista. Having a good sense of the differences might help clarify things.

IE6 is integrated with the shell, so that opening local folder paths will open in the browser. IE7 will always open a new window in this case.

IE7 in protected mode on Windows Vista will open a new window if necessary, depending on whether the page should be opened as a low or medium-integrity process. For example, clicking a link in a LOW window might open a MEDIUM window (or vice versa), if the target of the link is in a different security zone. In Windows XP, this is not the case.

Launching IE from CoCreateInstance will always create a new browser window, but ShellExecute (or System.Diagnostics.Process.Start) may not, depending on the user's default settings for launching shortcuts. Moreover, the behavior of new tabs is also a user setting, found by opening Tools > Internet Options, and clicking the Settings button on the General tab, Tabs section. The "Open links from other programs in:" setting allows you to open shortcuts in: a new window, a new tab in the current window, or the current tab/window.

As you can see, the user is in control.

As a developer, your only real option is to TARGET a window by name. If the window doesn't exist, it will be created for you. You can't do this with a simple ShellExecute, however.






Re: Internet Explorer Extension Development Opening web page from Windows application opens in new tab

brianpmccullough

Perhaps something for the next revision, update, service pack, or major version of IE would be to allow us developers to specify whether we want the link to launch in the current tab of the current window, new tab in current window, or new window. Many of the users don't understand these settings, but expect things to work a certain way for certain applications.

-Brian