ShowDialog or Show

  • Thread starter Thread starter Peter B
  • Start date Start date
P

Peter B

I have a form that I show with form1.ShowDialog() and wait for an
DialogResult. Depending on the result different things will happen.

In the dialog I have a "help" bbutton, which executes the peghelp.exe
applications with a html-help file as argument (Using OpenNETCF.org's
CreateProcess... When I do this the dialog seems to return (without me
setting DialogResult). This seems to happen when the help file isn't found
and a messagebox is shown in the peghelp application.

I have looked around for information on how ShowDialog works but I can't
understand this behaviour and it really messes my application up. Does
anyone have an explanation?

To solve this, would it be a better choice to use form1.Show instead? In
that case I need to come up with a way of knowing the users choice, but that
is another question...

best regards,

Peter
 
Peter,

The main difference between Show and ShowDialog is that ShowDialog should
behave modally. There are other ways to communicate the user's choice (such
as setting a public property on the parent form), so if Show behaves more
the way you want, I'd go that route.
 
Thanks for replying Ginny!

Yes I will use Show, and I do understand why. What I don't understand is why
the modal form returns to the parent form when I start another application
from it which inturn opens a modal dialogbox?

Form1 runs Form2.ShowDialog()
Form2 executes CreateProcess("peghelp.exe", "myhtml.html") but the html file
doesn't exist so a dialogbox is displayed.
Now without doing anything, Form2 terminates and returns to Form1 which
processes it's DialogResult (which was never set).
The result of Form2's termination could be displaying some information to
the user from Form1 which makes things really messy, since I am in the help
application :-)

This is when you wonder if you should persue this any further or just let it
be and do what was suggested...

thanks,

Peter

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Ginny Caughey said:
Peter,

The main difference between Show and ShowDialog is that ShowDialog should
behave modally. There are other ways to communicate the user's choice (such
as setting a public property on the parent form), so if Show behaves more
the way you want, I'd go that route.
 
Peter,

I agree that this is unexpected behavior (to me anyway). I'll see what I can
find out.
--
Ginny Caughey
..Net Compact Framework MVP

Peter B said:
Thanks for replying Ginny!

Yes I will use Show, and I do understand why. What I don't understand is why
the modal form returns to the parent form when I start another application
from it which inturn opens a modal dialogbox?

Form1 runs Form2.ShowDialog()
Form2 executes CreateProcess("peghelp.exe", "myhtml.html") but the html file
doesn't exist so a dialogbox is displayed.
Now without doing anything, Form2 terminates and returns to Form1 which
processes it's DialogResult (which was never set).
The result of Form2's termination could be displaying some information to
the user from Form1 which makes things really messy, since I am in the help
application :-)

This is when you wonder if you should persue this any further or just let it
be and do what was suggested...

thanks,

Peter
 
Back
Top