Re: Hiding all open forms

James Berry <[email protected]> Tue, 27 Nov 2007 14:56:57 +0000
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
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
>