SOS - Click Events in .NET

Status
Not open for further replies.

sarabjit

Solid State Member
Messages
11
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. (http://msdn.microsoft.com/library/d...fsystemwindowsformscontrolclassclicktopic.asp). 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.

It'll be great if someone can help me understand this translation between the OS and the .NET. Any help is greatly appreciated.

Thanks..

Sarabjit.
 
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?
 
Status
Not open for further replies.
Back
Top Bottom