Dialog owner in MDI forms

  • Thread starter Thread starter Grober Myttelson
  • Start date Start date
G

Grober Myttelson

MyMDIChild is an MDI child to MyMainForm. When I run the following code the
MDI child gets to be the owner of the dialog.

MyDialog d = new MyDialog();
if (d.Init())
{
d.Owner = MyMDIChild;
f.ShowDialog();
}

But when I run this code MyMainForm gets to be the owner.

MyDialog d = new MyDialog();
if (d.Init())
{
f.ShowDialog(MyMDIChild);
}

Why doesn't it work the same way in the second example?

Regards
/Grober
 
What is f in your code?

f.ShowDialog(MyMDIChild); sets f's owner to be MyMDIChild while
d.Owner = MyMDIChild; sets d's owner to be MyMDIChild. ????

=================
Clay Burch
Syncfusion, Inc.
 
Sorry, it should be d there too of course. Thus my post should read like
this:

MyMDIChild is an MDI child to MyMainForm. When I run the following code the
MDI child gets to be the owner of the dialog.

MyDialog d = new MyDialog();
if (d.Init())
{
d.Owner = MyMDIChild;
d.ShowDialog();
}

But when I run this code MyMainForm gets to be the owner.

MyDialog d = new MyDialog();
if (d.Init())
{
d.ShowDialog(MyMDIChild);
}

Why doesn't it work the same way in the second example?

The question is still the same.

/Grober
 
Hello Grober,
But when I run this code MyMainForm gets to be the owner.

MyDialog d = new MyDialog();
if (d.Init())
{
f.ShowDialog(MyMDIChild);
}

Why doesn't it work the same way in the second example?

This code uses an algorithm in the ShowDialog method, that finds the
ultimate parent of the control you pass in, and in the case of an MDI
child form, that is the MDI parent.


Oliver Sturm
 
Ok, I see. Thanks.

/Grober


Oliver Sturm said:
Hello Grober,


This code uses an algorithm in the ShowDialog method, that finds the
ultimate parent of the control you pass in, and in the case of an MDI
child form, that is the MDI parent.


Oliver Sturm
 
Back
Top