tags:

views:

87

answers:

4

I have code that opens a new window but I want to be able to edit the same one.

System.Diagnostics.Process.Start("iexplore.exe", "http://www.live.com")
A: 

I'm not sure exactly but a good pointer to start off might be to get the handle of the window you're interested in:

http://www.pocketpcdn.com/articles/dotnetcf_hwnd.html

And then separately investigate what interop messages you can send to IE to change the URL in tab X

joshcomley
Why has this been voted down?! It sounds like you want to do something IE specific and as far as I'm aware IE does not have a .NET interface
joshcomley
IE does have a COM interface, and COM is usable from .NET.
John Saunders
A: 

In order of increasing difficulty and increased control/power:

  1. Send input text to your IE process. Alt-D to focus on the navigation bar, then the URL, then ENTER.
  2. Use MSAA to find the navigation bar and send it text, as above.
  3. Use MSAA to get IHTMLDocument access to the browser, and then programmatically drive the browser with that, and the related interfaces.

I don't know your exact scenario, but if you can host your own instance of MSHTML, or a WebBrowser control, it will make it a lot easier to get the interfaces and do the manipulations mentioned in #3 above; doing that stuff cross-process is fraught with peril.

I just did a web search and turned up a WatiN tool that apparently wraps a lot of this work; perhaps it would be useful for you.

Bruce
A: 

If you are using 2008 there is a feature where you could create a second form and then add a Webbrowser control

the page could then be called by

myForm.show

The page could then be changed with the

Webbrowser1.Url = New Uri("http://www.google.com")
Chromableed Studios
A: 

Use the following code:

System.Diagnostics.Process.Start("http://www.live.com")

That is: do not invoke iexplore.exe directly – just let the system figure out which default browser to open.

This may yield two behaviours:

  • Either it opens a new tab in an existing Internet Explorer window,
  • or it creates a new window.

The important point is that this depends on a preference that can be controlled within the Internet Explorer application. If a new window opens, then this is the setting chosen by the user – do not try to override it: overriding the user’s preferences is considered bad manners.

If the users don’t want a new window opened, they can simply change that in their Internet Explorer preferences.

Konrad Rudolph