Try:
Dim f As Form
For Each f In Me.MDIChildren
f.Close()
Next
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"CBanu [IXIA]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have an application that connects to a server. The server might send
> an event that should cause my app to go offline. However, the user
> could have at that particular moment a wizard (in the form of a modal
> dialog), which also could have other modals or message boxes on top of
> it. When I receive the event, I want to be able to close the wizard
> along with all its modal 'children'.
>
> There was a solution, in having the modals listen for a particular
> event, and close when they received it. However, as I said, I could be
> using message boxes also. So I can't have those listening for the
> event.
>
> I need something like running through the forms of my app, and see if
> they're on top of the given form. Then call Close() if that's the case.
>
> I'm looking forward for your feedback.
>
> Thanks in advance,
> Cosmin.
>