CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2007
    Posts
    274

    [RESOLVED] Show webpage in a new window?

    How can I use the process class to launch the default browser in a new window.

    Process.Start("www.google.com"); does not work. It will open a new tab in an exisiting IE instance.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Show webpage in a new window?

    I'm amazed that even works at all. It does, I tested it, but seems odd. Anyway, you can launch the user's default browser as the process instead and pass the url as a command line argument.

  3. #3
    Join Date
    Mar 2007
    Posts
    274

    Re: Show webpage in a new window?

    Quote Originally Posted by BigEd781 View Post
    I'm amazed that even works at all. It does, I tested it, but seems odd. Anyway, you can launch the user's default browser as the process instead and pass the url as a command line argument.
    Thanks for responding. By providing just the url, it will ensure that whatever the default browser is set to will launch the page. But my problem is I need the page to launch in a new window. I only use I.E., but I believe firefox, and oprah (lol, ... sorry opera) browsers use tabbed browsing as well. I need the browser to launch in a new window for the task I have at hand. I have already tried specifically launching I.E and setting the argument, and the result is the same.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Show webpage in a new window?

    Thanks, didn't know that. If you start the browser by its executable path with the url as an argument I thought that it starts a brand new process, i.e., new window. let me check..
    Last edited by BigEd781; January 18th, 2009 at 07:45 AM.

  5. #5
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Show webpage in a new window?

    Yup, this code opens a new window for me every time. However, if I go for the default http\shell\open command, it opens another tab for me in firefox.

    Code:
    public partial class Form1 : Form
        {
            public Form1()
            {
                Process.Start(GetDefaultBrowserPath(), "www.google.com");           
            }
    
            private string GetDefaultBrowserPath()
            {
                //string key = @"http\shell\open\command";  <--opens a new tab
                string key = @"htmlfile\shell\open\command";
                Microsoft.Win32.RegistryKey registryKey =    
                     Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(key, false);            
    
                return ((string)registryKey.GetValue(null, null)).Split('"')[1];
            }
        }

  6. #6
    Join Date
    Mar 2007
    Posts
    274

    Re: Show webpage in a new window?

    well, that worked, but I'm still in a bind.

    I'm trying to setparent for the browser window.

    Any ideas?

    Here's basically what I got:

    Code:
                Process PR = new Process();
                PR = Process.Start(GetDefaultBrowserPath(),"www.yahoo.com");            
                PR.WaitForInputIdle();
                //System.Threading.Thread.Sleep(10000);
    
                SetParent(PR.MainWindowHandle, thisPanel2.Handle);

    I can not find anything about changing a webbrowser's parent, specifically I.E. on google. I am creating a new thread here and marking this thread resolved.
    Last edited by Traps; January 18th, 2009 at 09:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured