Hey guys. I have a question. In my program, I'm calling a Process (Internet Explorer) on button click, but I want to customize the size of the IE window being opened to something like 800 x 600 pixels. Do you know how do it? Below is my base code.

Process p = new Process();
p.StartInfo.FileName = "IExplore.exe";
p.StartInfo.Arguments = target; //target is a string -- this is the link that I'm opening
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

I know I have to use API. I tried to use below code, but the window is not resizing. What happens is it sticks to the previous location and size of the previous internet explorer that I executed. Say I opened an IE, resized it manually to 300 x 300. The next time I click the button and call my functions to resize, it still opens the 300 x 300 that I left.

IntPtr hWnd = (IntPtr) p.MainWindowHandle.ToInt64();
RECT rect = new RECT(new Point(500, 500), new Size(800, 600));
GetWindowRect(hWnd, out rect);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
MoveWindow(hWnd, rect.Left, rect.Top, width, height, true);

Thanks a lot!

6 Years
Discussion Span
Last Post by Lusiphur

Try the code sample at this page as it seems to do exactly what you want.

Seems to be a combination of C# and JavaScript coding to accomplish the effect.

Hope this helps :) Mark as solved if it does.

Edit: As a side note, the above sample appears to be for a web-app deployment, if you're working on a windows forms app then the sample may not work the same in a non-browser environment.

Edited by Lusiphur: n/a


thanks for the answer. but i'm working for a Windows Application, so it's not applicable. :)


Yes and no... You're working on a windows application but you're calling your process in a browser which is why I figure that this *might* just work. Couldn't hurt to give it a try, no? :P


Another resource to look at (if you haven't already) is at this page.

Shows the use of the InternetExplorer object class which has adjustable properties including height and width.

hey dude. thanks a lot! this helped me solve my problem. this is what I'm looking for. you're amazing! :icon_cheesygrin:

i just used the Height and Width properties.

SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
object Empty = 0;
object URL = target; //the link that I'm going to open

IE.Visible = true;
IE.Width = 800;
IE.Height = 600;
IE.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);

Edited by kurtzky: n/a


Glad I could help :) Don't forget to mark solved so others don't think the issue is still unresolved.

Edited by Lusiphur: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.