c# - Fit the process in the container Form -
i want start process in c# application , able using code:
processstartinfo startinfo = new processstartinfo(); startinfo.filename = "chrome.exe"; startinfo.workingdirectory = @"c:\program files\google\chrome\application"; process process = process.start(startinfo); but when open opens on whole screen, means covers whole screen. need contained within boundary of form. lets size of form 906, 495 application should open within area.
i unable find that how can this. secondly need set size of application. have used chrome may other process. possible?
you can this:
[dllimport("user32.dll", setlasterror = true)] internal static extern bool movewindow(intptr hwnd, int x, int y, int nwidth, int nheight, bool brepaint); processstartinfo startinfo = new processstartinfo(); startinfo.filename = "chrome.exe"; startinfo.workingdirectory = @"c:\program files\google\chrome\application"; //force chrome run in new process startinfo.arguments = @"--user-data-dir=c:\sometempdir"; process process = process.start(startinfo); process.waitforinputidle(); //need little more work create sure window handle { system.threading.thread.sleep(100); process.refresh(); } while (process.mainwindowhandle == intptr.zero && !process.hasexited); //set these appropriately int xpos = 0; int ypos = 0; movewindow(process.mainwindowhandle, xpos, ypos, 906, 495, true); c# process
No comments:
Post a Comment