C# .NET - Open window Form in a new Page/Window

Asked By Arth Srivastava on 28-Apr-09 05:08 AM
Hi All,
  I am involved  in  Windows application Project.
The question is quite simple ...
i have a Link on Form1 and on that Click of LINK  , i have to open
http://www.google.com in a New Window /Page...


Please suggest...

Thanks,
Arth

ProcessClass

Kalit Sikka replied to Arth Srivastava on 28-Apr-09 05:14 AM

Use Process Class to open new window

Put this code under the click event of LinkButton on Form1

Process MyProcess = new Process();

MyProcess.StartInfo.FileName = "http://www.google.com"; // Your Link

MyProcess.StartInfo.CreateNoWindow = true; // Newwindow

MyProcess.StartInfo.UseShellExecute = false;

MyProcess.StartInfo.RedirectStandardInput = true;

MyProcess.StartInfo.RedirectStandardError = true;

MyProcess.Start();


Vasanthakumar D replied to Arth Srivastava on 28-Apr-09 05:16 AM

Hi,

try this

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

{

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

}

Thanks

Arth Srivastava replied to Vasanthakumar D on 28-Apr-09 05:29 AM
Thanks,
    VasantKumar :)
can we adjust the Window size also likeways we do in opening new windows in Javascript in web applications...??

Thanks,
Arth
do like thsi way
Ravenet Rasaiyah replied to Arth Srivastava on 28-Apr-09 05:56 AM
hi

to button click

  Process process = new Process();
            process.StartInfo = new ProcessStartInfo("iexplore.exe","http:/www.google.com");           
            process.Start();
there is no direct method for this... but you can overwrite the registry keys to set the heignt and width..
Vasanthakumar D replied to Arth Srivastava on 28-Apr-09 06:09 AM
end of post
For Adjusting window size you should use this
Kalit Sikka replied to Arth Srivastava on 28-Apr-09 06:12 AM
    public static void mOpenFile(string URL)
        {
       
        Screen scr = Screen.PrimaryScreen;
        int oldWidth = scr.Bounds.Width;
        int oldHeight = scr.Bounds.Height;
        Process proc = new Process();
        proc.StartInfo.FileName = URL; // put full path in here
        proc.StartInfo.WindowStyle =ProcessWindowStyle.Maximized; // This property have four options Maximum, Minimum, Hidden, Normal
        proc.Start();
        proc.Dispose();
        }
can we open the window in Firefox or Chrome also??
Arth Srivastava replied to Vasanthakumar D on 29-Apr-09 07:24 AM

can we open the window in Firefox or Chrome also??

If yes ..then How..??

Thanks,
Arth
Vasanthakumar D replied to Arth Srivastava on 29-Apr-09 07:34 AM

Hi,

yep you can ....

just change the exe name of the brwose like

for firefox

System.Diagnostics.Process.Start("firefox.exe", http://www.google.com);

for chrome

 System.Diagnostics.Process.Start("chrome exe name", http://www.google.com); //i dont know exe name, becuase I am not using it.. lol

thanks
Arth Srivastava replied to Vasanthakumar D on 29-Apr-09 08:24 AM
Thanks and end of Post :)
welcome buddy...
Vasanthakumar D replied to Arth Srivastava on 29-Apr-09 08:25 AM
end of post