Process A starts process B. How does process A ensure that process B's window runs modally?
Printable View
Process A starts process B. How does process A ensure that process B's window runs modally?
I hope this worksBy the way, it's 2.0Code:Control c = Control.FromHandle(proc.MainWindowHandle);
if(c is Form){
return ((Form)c).Modal;
}
Thanks. Even though that code doesn't work (because c always evaluates to null), I got a cue enough to wend my way:
At least I got a handle of that process, which if I were on my own, I would have procured through PROCESS_INFO, CreateThreadProcessID, GetWindowFromProcessID etc.
Now, I can call SetParent(hWnd, hWndParent) on that window handle. Won't make it modal but will help a great deal.
Thanks again.
I'm not sure that you understand what "modal" means. A modal window is one that sits on top of another and doesn't allow access to that other form until the modal form is dismissed. If you want your app to do that with an external executable then you do it like this:Now your app will block until the app you started exits. If you want to do this with an existing process then you need to create a Process object for that running process.VB Code:
Process p = Process.Start("executable path here"); p.WaitForExit();
From what you posted in post #3 it looks like you want to make an external application's window an MDI child of your own. Which is it?