Saturday, 17 August 2013

Show form modal on top of another process

Show form modal on top of another process

I've tried doing that, and ended up with the following code;
var proc = Process.GetProcesses().Where(x => x.ProcessName ==
"notepad").First();
IWin32Window w = Control.FromHandle(proc.MainWindowHandle);
using (Form2 frm = new Form2())
{
frm.ShowDialog(w);
}
However, that doesn't display the form as a modal on top of "notepad", for
some reason, why's that? What I want to achieve is: Being able to display
a modal on top of notepad. Thanks!

No comments:

Post a Comment