Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

Modal forms, Owner property and minimization behaviour

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dancardoso@gmail.com - 02 Aug 2006 04:32 GMT
Hi everybody,

I believe something weird is happening with my windows forms desktop
application. I have a main form (Form1, shown using Application.Run)
and this main form opens a modal form (Form2), using ShowDialog(this)
so that the owner of Form2 is Form1. Form2 does the same thing with
Form3 (ie, Form2 opens Form3 modally, using showDialog(this.Owner), so
that the owner of Form3 is Form1 too. Form3, once more, opens Form4
passing a reference to Form1 in the owner parameter of showDialog.

The weird thing happens now: Form4 has a button that minimizes the
application when clicked by setting Form1.WindowsState to Minimized.
When Form1 is minimized, all its 3 owned forms are minimized too. 'til
this point, everything's fine, but when Form1 is restored, only Form1
itself appear and I can freelly use it. The other modal windows do not
come back with Form1. Indeed, after some debugging I realized they were
being closed just after form1's minimization. Is this really the
expected behaviour?

What I need to do is to minimize the application and when the user
restores it, all 4 forms are shown as before minimizing. Is there any
way I can accomplish this? The reason for that is that in the real
application, the last form has a functionality to start another process
and I want the hole app to minimize so that the user can work with the
just-started application. After finishing work, the user should be able
to go back and restore the first application to continue working.

Thanks and sorry for the long post.

Daniel.
dancardoso@gmail.com - 02 Aug 2006 13:59 GMT
Just in case anyone goes through the same situation, I just realized
that if I minimize the child form (i.e. Form4 in the example), all the
owner forms are minimized too. That's the behaviour I want. I just
still can't understand the logic behind this because I imagined that
the childs should minimize with the parent, not the opposite.

> Hi everybody,
>
[quoted text clipped - 26 lines]
>
> Daniel.
AnsweringMachine - 03 Aug 2006 05:03 GMT
I digged for a while and it turned out that even if I explicitly kept
references (as opposed to relying on the references in the main form's
OwnedForms collection) to all these form objects, the owned modal
dialog boxes still got closed and their references removed from the
OwnedForms collection after the main form got minimized and restored.
And the CloseReason on the closed forms were None, the description of
which is "The cause of the closure was not defined or could not be
determined."

I guess the logic behind this is that modal dialog boxes are supposed
to be 'modal', meaning they are supposed to remain on the screen for a
short while and get dismissed after taking input from the user. If you
want something that moves and changes with the owner form, you might
have to use modeless dialog boxes.

> Just in case anyone goes through the same situation, I just realized
> that if I minimize the child form (i.e. Form4 in the example), all the
[quoted text clipped - 32 lines]
> >
> > Daniel.
kaisatsu - 31 Aug 2006 05:52 GMT
I've encountered the same problem and also realized that in this case,
the modal
Form's OnClosing event is being called, but not OnClosed, which will
actually only be called if the DialogResult is set on the modal form.

Unfortunately, I'm still searching for a good solution to keep the
modal form around!

-Meg

> Hi everybody,
>
[quoted text clipped - 26 lines]
>
> Daniel.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.