Hiding all open forms

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