Re: Hiding all open forms

Mike Andrews <[email protected]> Tue, 27 Nov 2007 10:58:28 -0600
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
I'm not getting that behavior when I'm testing this.
Application.OpenFormsgets forms even if the ShowInTaskbar = false is
set.
Are you using MDI child forms?

On Nov 27, 2007 10:51 AM, James Berry <[email protected]> wrote:

> See my original posting: Application.OpenForms doesn't return any forms
> where ShowInTaskbar = false  -- this is actually my main problem
>
> I don't have many (if any) standard MessageBox's in the application (since
> I've replaced them with my own lookalike) but it'd be nice to cope with
> standard MessageBoxes if I can.  Which I would be able to if there were a
> way to enumerate all form window handles on a particular thread (not sure if
> this is possible, hence my original posting!)
>
> 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 16:27
> To: [email protected]
> Subject: Re: [DOTNET-WINFORMS] Hiding all open forms
>
> Why is not Application.OpenForms reliable?
> Oh, you're also talking about standard MessageBoxes then as well?
>
> On Nov 27, 2007 10:24 AM, James Berry <[email protected]> wrote:
>
> > Most do (all could if I had to).  But some forms have owned windows for
> > pop-ups, and there are standard messagebox's to think about...
> >
> > But surely I can send messages to it knowing the handle anyway using
> Win32
> > SendMessage on the right thread through SynchronixationContext .  So if
> I
> > could reliably find all open windows (and OpenForms isn't reliable in
> this
> > regard), then I can send messages to move/resize forms.
> >
> > 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 16:09
> > To: [email protected]
> > Subject: Re: [DOTNET-WINFORMS] Hiding all open forms
> >
> > The reason I ask about the base dialog, is that I do have a solution for
> > you.
> > If there is a base dialog form, you can override the WndProc and use the
> > Control.ReflectMessage method in the alternate thread to send a custom
> > message to the dialog form.
> > You will have to use the SetBounds method of the form to move it off the
> > screen, but that's easily overcome.
> > I have a sample that I can send to you if you want.
> >
> > Thanks,
> > Mike
> >
> > On Nov 27, 2007 9:05 AM, James Berry <[email protected]> wrote:
> >
> > > 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
> > > > >
> > > >
> > >
> >
>