Re: Hiding all open forms

James Berry <[email protected]> Tue, 27 Nov 2007 15:05:06 +0000
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
The majority of the forms are non-modal.  But a modal dialog may well be present.  And of course there are the usual number of owned forms etc.

As you say, there is no centralized tracking of forms currently.

The "locking" code actually runs on a different thread, and uses a synchronizationcontext to make sure the changes to the forms happen on the right thread. That's fine; it's reliable identification of the forms and then what to do with them that is the issue ;-)

Best wishes
James


-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Mike Andrews
Sent: 27 November 2007 14:59
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] Hiding all open forms

Are these non-modal dialogs?
I'm also assuming there's no central place where all forms are tracked?
On Nov 27, 2007 8:56 AM, James Berry <[email protected]> wrote:

> I actually need to hide all the forms that are currently active; show an
> application security window, and once the criteria in that window have been
> met I re-show the old forms again to continue where they left off.
>
> The issue with dialog boxes is that if I can identify that they're there
> (either with OpenForms or some other way), if I change their visibility to
> false, or send a window hide message to the form, then what actually happens
> is that DialogResult gets set to Cancel, and the value is returned to the
> calling function.  Which I need to avoid if I am going to put things back
> the way they where, which is why I wondered if there was a more imaginative
> solution than moving the windows off screen, or resizing them, or both.
>
> Best wishes
> James
>
>
> -----Original Message-----
> From: Discussion forum for developers using Windows Forms to build apps
> and controls [mailto:[email protected]] On Behalf Of
> Mike Andrews
> Sent: 27 November 2007 14:52
> To: [email protected]
> Subject: Re: [DOTNET-WINFORMS] Hiding all open forms
>
> Is the specific requirement that they all hide/show at once?
> Or is it that when the "close" they don't really close you just hide them
> for later use?
>
> Thanks,
> Mike
>
> On Nov 27, 2007 8:47 AM, James Berry <[email protected]> wrote:
>
> > I need to hide all open forms in my application (and be able to bring
> them
> > back later).  This is a security function for which there is an external
> > requirement, and I can do nothing to manage.
> >
> > My first test was to use the Application.OpenForms to discover all open
> > forms and then hide them.  This gives two sets of problems:
> >
> > 1. OpenForms does not include forms where ShowInTaskBar = false
> > 2. Hiding open dialog boxes causes them to close (returning
> DialogResult).
> >
> > So, any pointers?
> >
> > 1. Is there a way to identify all open forms without OpenForms (Win32
> > functions to find the handles would be enough probably, as I can always
> send
> > messages rather than using the dotnet functions)
> > 2. Is there a good alternative to hiding?  I thought of resizing to 0,0
> -
> > or moving massively off screen (eg to 10000, 10000)
> >
> > Best wishes
> > James
> >
>