Click Events in .NET

sarabjit

New Member
Here's something I wish to learn about how Windows OS interacts with .NET:

Every Windows Forms Control has the ability to handle one or more mouse actions - left click, double click etc. For example, .NET allows this by generating a Click event for the relevant control everytime the mouse is left clicked.

What I wish to understand is that how does .NET know which Control to generate the Click event for. In other words, if I click on a particular button, the OS recognizes the point on the screen where the click occurs, then translates that information and sends it to .NET which identifies which control does the click correspond to. That, at least, I believe is the chronology.

But I'm not sure how this translation between the OS and .NET takes place. Any help is greatly appreciated.

Thanks..

Sarabjit.
 
Elaboration

Some more info..

Here's as far as I've been able to get. The following is the chronology of actions that take place after a click:

Step 1. mouse is clicked

Step 2. windows detects the mouse click through the driver, and sends the input to the relevant process

Step 3. the OnEventName() method of the respective control in the process is called along with the event data as the argument
the definition of each Forms.Control class already consists of a definition for this method; the user does not need to worry about including it in his/her application

Step 4. the OnEventName() method references the respective delegate
delegates for different event handlers for any Forms.Control are also automatically added to the corresponding instances by .NET directly

Step 5. the delegate then makes a call to the event handler written by the user
this is the event handler which describes what should happen when the event occurs; this is also the method which needs to have the same signature as the corresponding delegate it uses

The missing pieces of information are in:
Step 2: What determines the choice of the relevant process?
Step 3: What determines the choice of the relevant control in the process?

Any clues?
 
I am wondering why this information is necessary?

.NET allows you to manipulate many things like declaring a data grid.. but I still dont know whats going on within the closed doors Microsoft's OS.

Theres more than one language in .NET.. VB, C++, C#.. but the interaction between the mouse/keyboard and an event correctly being sent to a .Net Application is beyond my knowledge.

In VB every object has a set of properties and a set of event handlers.

If I name a command button cmdButton, and then click on that button that object now has focus. The focus event handler _GotFocus occurs FIRST, then the single click is registered and you go to the _Click event.

Its seems like you are asking how the OS intreprets the 1's and 0's the mouse click sends to the driver.. etc..

All I know, and all you and I (as programmers) need to know is that a click is a click... and KeyPress is KeyPress...

everything in .NET is a class... maybe checking out the many classes that run without our knowledge is your best bet.
 
Back
Top