Is such a thing possible? For example, I have an app that has a form, MyForm. Is it possible to find all instances of MyForm that exist at the time I look for them?
Printable View
Is such a thing possible? For example, I have an app that has a form, MyForm. Is it possible to find all instances of MyForm that exist at the time I look for them?
if you want the forms in your App, you can do the following...
otherwise , i've put a system wide enumeration below it, hope it gets you on the way :)
VB Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button1_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button1.Click [COLOR=BLUE]Dim[/COLOR] objType() [COLOR=BLUE]As[/COLOR] Type = Reflection.Assembly.GetExecutingAssembly.GetTypes() [COLOR=BLUE]Dim[/COLOR] x [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Integer [/COLOR] [COLOR=BLUE]For[/COLOR] x = LBound(objType) [COLOR=BLUE]To[/COLOR] UBound(objType) MessageBox.Show("forms in your app are: " & objType(x).Name) [COLOR=BLUE]Next [/COLOR] [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
but if you want system wide , maybe you need to enumerate the processes , like this.....
VB Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Button2_Click([COLOR=BLUE]ByVal[/COLOR] sender [COLOR=BLUE]As[/COLOR] System.Object, [COLOR=BLUE]ByVal[/COLOR] e [COLOR=BLUE]As[/COLOR] System.EventArgs) [COLOR=BLUE]Handles[/COLOR] Button2.Click [COLOR=BLUE]Dim[/COLOR] procs() [COLOR=BLUE]As[/COLOR] Process = Process.GetProcesses() [COLOR=BLUE]Dim[/COLOR] x [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Integer [/COLOR] [COLOR=BLUE]For[/COLOR] x = LBound(procs) [COLOR=BLUE]To[/COLOR] UBound(procs) ListBox1.Items.Add(procs(x).ProcessName & " : " & procs(x).MainWindowHandle.ToInt32) [COLOR=BLUE]Next [/COLOR] [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]
That enumerates all types in an assembly. But will it enumerate the instances of a type that may be created and destroyed at runtime?
not tried that yet lol, but something you may recognize lunatic...
.....Quote:
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
very good album is brave, although seasons end is my favourite post - fish marillion album. seen em around 15 times or so since the mid 1980's in concert:cool:Quote:
Heading for the great escape
heading for the rave
heading for the permanent, holiday.
Yes, Seasons End is my favorite too.Quote:
Originally posted by dynamic_sysop
very good album is brave, although seasons end is my favourite post - fish marillion album. seen em around 15 times or so since the mid 1980's in concert:cool:
I love them though never had the chance to see them in concert (due to living in Iran), however I am moving to Canada soon and hope they care to come to Vancouver and play there. Recently I had a chance to see a show of them playing at MCM cafe in Paris. They played "The Great Escape" just great. As a Marrillion fan you may be an Eloy fan too? Right?
i have listened to eloy, but not really got in to them. my cousin in holland has all their stuff though ( he's mad on prog rock ), he used to help running the dutch marillion fanclub. good to see someone else with great tastes in music on here :D
Especially if from Axis of Evil :DQuote:
Originally posted by dynamic_sysop
good to see someone else with great tastes in music on here :D
Hey, stop hijacking my thread, or I'll give out some serious ass punching!
;)
Ass punching? I thought you were supposed to kick the ass! :DQuote:
Originally posted by crptcblade
Hey, stop hijacking my thread, or I'll give out some serious ass punching!
;)
If you mean for a specific project then you could use some form of factory design to control the different instances. You'd think that the GC has to track instances and we can sort of access it that we could get the info but I couldn't find away to get instance information.
Super dooper bump!
:afrog:
Hmm I dont know if it registers classes System or App-wide but you could try designing classes that would have a static class that everytime you'd instanciate a class you'd add a reference to that static method
hmm hope you understood :S
I understand, but I was under the understanding that it only be in the scope of the application. I'll have to test some things out then, thanks.