Controls and event handlers  
Author Message
mattdawg





PostPosted: Windows Forms General, Controls and event handlers Top

I am trying to write a program that traces every button press. I am doing it by tracing the clicks. The problem is that I also get when the form is clicked which I don't want. So I am trying to use the event.IsMulticast to see if my event handler that I assign while finding every thing that is clicked is the only one or if one was programed in also. But it's not working it's still picking up when people click on the form. Is there a better way to do this Do you even understand what I am talking about

mSequence = new WeakReference(sequence);

mID = component.ToString() + "_" + evt.Name;

evt.AddEventHandler(component, new EventHandler(HandleEvent));

if (evt.IsMulticast)

{

...

}

Here is some code to help you understand a little about what I am doing. I just need to know if control already has a "click" event handler.



Windows Forms30  
 
 
mattdawg





PostPosted: Windows Forms General, Controls and event handlers Top

I might be able to fix this if I can find out what parent form is calling this control. Does anybody know how to find a controls parent through reflection or any other way. This program is a library that the calling assembly is using to trace where users are going in the form. Any clue's
 
 
Chris Vega





PostPosted: Windows Forms General, Controls and event handlers Top

I don't think there's a way in reflection to determine which parent control (container) owns a specified control, other than checking the TopLevelControl property on runtime.

-chris