Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

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.

On Wed, 06 Jun 2007 10:46:00 -0700, Frank Rizzo <n@none.com> wrote:
> [...]
> 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

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc