How do I open maximized internet explorer?

浪尽此生 提交于 2019-12-05 14:52:16
N1C0

I would use the process method.

  1. You could start any executable and
  2. It has a property which starts your process maximized

    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
    startInfo.Arguments = "www.google.com";
    
    Process.Start(startInfo);
    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Maximize_IE
{
    class Program
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        static void Main(string[] args)
        {
            var IE = new SHDocVw.InternetExplorer();
            object URL = "http://google.com/";

            IE.ToolBar = 0;
            IE.StatusBar = true;
            IE.MenuBar = true;
            IE.AddressBar = true;

            IE.Visible = true;
            ShowWindow((IntPtr)IE.HWND, 3);
            IE.Navigate2(ref URL);
            //ieOpened = true;
        }
    }
}
Ihor Deyneka

Quick google of "csharp maximize SHDocVw window" gives this example:

[DllImport ("user32.dll")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
private const int SW_MAXIMISE = 3;

public void OpenWindow()
{
       SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();  //Instantiate the class.
        ShowWindow((IntPtr)ie.HWND, SW_MAXIMISE);   //Maximise the window.
        ie.Visible = true;   //Set the window to visible.
}

try this:

  var proc = new Process
            {
              StartInfo = {
                 UseShellExecute = true,
                 FileName = "http://localhost/client.html",
                 WindowStyle = ProcessWindowStyle.Maximized
              }
            };
  proc.Start();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!