How to know all forms Opened in current AppDomain?

J

John

Hi,

In VB.NET EXE project, if we enable application framework, we could use My.Application.OpenForms to get all open forms, but my question is how to enumerate all open forms without enable Application Framework, or in DLL project where you do not have choice to enable the framework but you do need to access the OpenForms information?

Thanks!
John
 
J

Jie Wang [MSFT]

Hi John,

Thank you for posting.

Let me give the straightforward answer first:

You can use System.Windows.Forms.Application.OpenForms to get the same
result.

VB.NET Code sample:

For Each f As Form In System.Windows.Forms.Application.OpenForms
MessageBox.Show(f.Text)
Next

Now let me explain a little bit more. Actually all the
My.Application.OpenForms property does is simply return the result from
System.Windows.Forms.Application.OpenForms.

When we enable the Application Framework for a VB.NET WinForm project, we
can access My.Application object, which is inherited from
WindowsFormsApplicationBase class located in
Microsoft.VisualBasic.ApplicationServices namespace (Assembly
Microsoft.VisualBasic.DLL). If you can find this assembly file and open it
using .NET Reflector or ILDasm, get to the source of
WindowsFormsApplicationBase.OpenForms property, you'll see a simple line of
code like this (which explains what I wrote in code):

Public ReadOnly Property OpenForms As FormCollection
Get
Return System.Windows.Forms.Application.OpenForms
End Get
End Property

So you can use System.Windows.Forms.Application's OpenForms property no
matter the Application Framework is enabled or not.

Please kindly let me know if I answered your question clearly, and if you
have any further questions on this topic, also feel free to post here.

Regards,

Jie Wang ([email protected], remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jie Wang [MSFT]

Hello John,

Would you mind letting me know if the
System.Windows.Forms.Application.OpenForms property is working for you?

If you have any further questions regarding this issue, please feel free
to let me know. I'd be happy to help.

Thanks,

Jie Wang ([email protected], remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top