Is there a way to pull out what forms are in a particular application that get's passed in Also does any one know how to find out the name of the exe file that call's the dll Anything would be very helpful.
Thanks,
Matt
Is there a way to pull out what forms are in a particular application that get's passed in Also does any one know how to find out the name of the exe file that call's the dll Anything would be very helpful.
Thanks,
Matt
pulling forms out of applications.
Andrew Oliver
zcz
Jiffy
I'm not sure the context in which your HookEvents is called, so I'm not sure what Form you're talking about.
If you just want the "active" form for the application you can iterate the Application.OpenForms property:
foreach(Form form in Application.OpenForms)
{
if(form.Active)
{
activeForm = form;
break;
}
}
Terry Nguyen
rradtke
WeldFire
In terms of Form-based classes contained in an assembly, you could use reflection to enumerate all the types in an assembly (see Assembly.GetTypes) and see if any derive from Form (see Type.BaseType).
You can get the main assembly via Assembly.GetExecutingAssembly(). If you have an object, and you want to know what assembly is is from you can use Object.GetType() to get it's type, then use the Type.Assembly property.
Sanket Shah
I guess I just don't understand how to access the form after you use Type.BaseType. Here is what I am trying to get it to work with. How do I pass the form into this function
private void HookEvents(Control ctl){
Type t = ctl.GetType(); EventInfo[] events = t.GetEvents(); foreach (EventInfo evt in events){
if (evt.Name == "Click"){
mActions.Add(new Action(ctl, evt, mSequence));
}
}
foreach (Control c in ctl.Controls)
{
HookEvents(c);
}
}
Itsme850
Carlos90210
Labm1ce