0

How can I have a black form as a background and some modal forms opened one at a time whose owner is the black form? I need these two to retain their order together (when minimized and maximized) that's why I have chosen the modal form.

I have made a simple main form with black background, and opened a form in dialog (modal) form. The main form provides a black background for me and the modal form stays in front of the black background. But when opening new forms, I can't set the owner of new modal form to the aforementioned black form. I have tried passing the black form object and also registering events to no avail.

Do you know any mechanism to implement the following scenario:

A black form as a background and a series of modal forms opened one at a time in front of the black one in a way that the black form is the owner of every modal form.

Thanks

Edit

Please consider this scenario: I have 3 forms named frmBlack, Form1 and Form2. I use frmBlack as the main blacked form. After placing a button on this form I call the Form1Object.ShowDialog(this). Now suppose that I want to navigate to the third form (Form2), [this means that I must close the Form1Object] I put a button on the second form (Form1) and when this button is pressed I must close the Form1 object and navigate to the Form2Object while its owner in the ShowDialog() function must be set to frmBlack.

Yasser Sobhdel
  • 611
  • 8
  • 26

3 Answers3

0

This is done using MDI Forms.

Your application will look like this: http://www.datadynamics.com/Help/AB3/Images/MDI%20Child%20menu.gif

This works in winform projects, not in WPF project (at least not by default).

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
0

Parent or Owner? That's a difference. Parent is only used in MDI-Applications (see Luigi's post). The owner can be set in the call to ShowDialog( owningForm ).

What is it that you want to achieve?

hth

Mario

Mario The Spoon
  • 4,799
  • 1
  • 24
  • 36
  • Owner is what I want. I don't want to get involved in painting the MDI form as stated in this post:http://stackoverflow.com/questions/1190395/how-to-remove-gray-background-on-mdi-parent-form – Yasser Sobhdel Mar 31 '12 at 08:05
  • To achieve what you want set the owner in call to ShowDialog (which would be your background window. That's how I do it. – Mario The Spoon Mar 31 '12 at 08:12
0

To achieve what you want from the window with the second button post pack to the frmBlack and let it do the work. Or more specifically set a flag within the frmBlack, since in frm1.btnShowNextForm you need to close frm1...

And also take a look at Form.Owner

so something along these lines in frm1.buttonShowNextFormClicked()

{
   if ( null != Owner )
   {
      FrmBlack frmBlackLocal = Owner as FrmBlack;

      if ( null != frmBlackLocal )
      {
         frmBlackLocal.NextAction = FrmBLack.NextActions.ShowForm2; //an enum
      }
   }

   Close();
}

and in frmBlack

{

   frm1.ShowDialog(this);

   if ( NextAction == NextActions.ShowForm2)
   {
      frm2.ShowDialog(this);
   }
}

Well, of course it needs some brush-up (like extracting the next handler in a function of it's own, but you should get the idea.

hth

Mario

Yasser Sobhdel
  • 611
  • 8
  • 26
Mario The Spoon
  • 4,799
  • 1
  • 24
  • 36