How to find loaded forms

Merchand

Well-known member
Joined
Dec 28, 2005
Messages
73
Location
USA Eastcoast
Programming Experience
10+
In Dot Net how do you find what winforms are loaded in one running applicaiton? I know you can do this with an API, but is there a way to do it natively in .net?

Also, is there a way to find out what applications are running on a system? (hence, in the the task manager) And is there a way to find out if your application is running in the task mananger. Trying to learn how to do old stuff in a new language (VB.net & C#).

Any help is greatly appreciated!:)

No API solutions please unless that is the only way.
 
Kulrom, thanks again!

I will R&D the process class and ActiveForm property.

Can I tell what forms are loaded for an application based on the ActiveForm?

Thanks! :)
 
ActiveForm/ActiveMDIChild will only the active one in your application.

Form.MDIChildren returns all mdi children forms that are loaded.

In a non-MDI application you can use the OwnedForms property to do the same if you also did set the Owner/AddOwnedForm before.
 
THis is how you can find which forms are opened/active
VB.NET:
[SIZE=2][COLOR=#008000]' Determine the active child form.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] activeChild [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Form = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ActiveMdiChild
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mylist [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ArrayList
[/SIZE][SIZE=2][COLOR=#0000ff]For [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] activeChild [/SIZE][SIZE=2][COLOR=#0000ff]In [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].MdiChildren
[/SIZE][SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] activeChild [/SIZE][SIZE=2][COLOR=#0000ff]Is [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]mylist.Add(activeChild.Text)
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] 
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] mylist.Count - 1
  Messagebox.Show(mylist.Item(i))
[/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]


Regards ;)

note: below is an attached project where you can see all that in deeds
 

Attachments

  • MDIforms.zip
    32.1 KB · Views: 25
Thanks Kulrom and JohnH for the feedback!

And thanks for the ideas and code samples...

* Owner/AddOwnedForm
* ActiveForm/ActiveMdiChild

I'll look at the Owner/AddOwnedForm on-line help and look at the ActiveForm too.
 
Back
Top