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;
p.Start();
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!