views:

101

answers:

1

I have two executables in C#, lets call them executable A and B, both of them have one form. Executable A gets the MainWindowHandle of B and then calls SetParent(this.Handle, B.MainWindowHandle). How can I set the form of executable B to be a Modal so that the form of executable A wont receive input unless I close the form B. Something like when you do frm.ShowDialog(). Thank you very much.

A: 

Well, given AForm and BForm, I've created a test project which references another Winforms project (which contains BForm), and I can do this:

private void button1_Click(object sender, EventArgs e)
{
  var bForm = new WindowsFormApplication2.BForm();
  bForm.ShowDialog(this);
}

With or without passing in an IWin32Window owner property to the ShowDialog function, mine correctly forces modal on my BForm.

Can you show us some code?

Matthew Abbott
I have to be more precise, while the above solution is perfect I will need to do it with Win32 API because the executable B might be a C++ or Visual Basic 6 program so I wont be able to call ShowDialog() with a C++ (for example) executable.
Ioannis