471,355 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

Form.ShowDialog() overloads

I am not grokking the difference between Form.ShowDialog() and
Form.ShowDialog(this). I have a form (parent form) that kicks off a
modal dialog using Form.ShowDialog(). The modal dialog has a 3rd party
control on it. The weird thing is that I can click on parent form's
icon in the taskbar and it will bring up the parent form (obscuring the
modal form). I can't do anything on the parent form (e.g. it does not
take mouse or keyboard input), so to users it looks hung.

If I only have native controls on the modal form, I do not see this
behavior (e.g. cannot bring up the parent form while the modal form is
showing).

The odd thing is that if I call the modal form using
Form.ShowDialog(this), the application behaves properly.

So it's probably something to do with the 3rd party control. Could it
be messing (is it even possible) with the ownership of the form?

Thanks.
Jun 6 '07 #1
1 2166
On Wed, 06 Jun 2007 10:46:00 -0700, Frank Rizzo <no**@none.comwrote:
[...]
So it's probably something to do with the 3rd party control. Could it
be messing (is it even possible) with the ownership of the form?
Yes. The parameterless ShowDialog() simply uses a "default" parent. When
you have the 3rd party control, this default parent is something other
than the parent form, causing the behavior you see.

For what it's worth, the default parent is whatever the "currently active
window" is. Obviously in the case of the 3rd party control, there's some
extra window running around that is treated as the "currently active
window". Assuming the 3rd party control is really just a control, this
seems wrong to me, but then there's lots of 3rd-party stuff out there
that's wrong.

Anyway, you found the appropriate work-around. When you care what the
parent is, you need to set it explicitly.

Pete
Jun 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chris | last post: by
4 posts views Thread by trialproduct2004 | last post: by
7 posts views Thread by pooba53 | last post: by
4 posts views Thread by hzgt9b | last post: by
8 posts views Thread by Ed Bitzer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.