Reputation: 1
I have a question how predifined events are working like button click,form load etc.Does the compiler send message to form class or button class when we click the button or form loading?I searched number of sites regarding this question but I didn't get answer.That sites show only how to create event and how to subscribe it.I am wondering to know that.If anyone know this please share me.
Upvotes: 0
Views: 52
Reputation: 56984
Those events are triggered when a certain Windows Message has been sent by Windows. The WndPrc method captures this message, and will this will eventually cause that the appropriate event is launched by the WinForms implementation. (Which is in fact a wrapper around the Windows API)
More information can be found here and here
You can also check out the source code of the WinForms Button class for instance, and see when the OnClick
event is raised. In the WndProc method you can see that the OnClick event is raised if a certain windows message (WM_COMMAND) with a certain value for the high order bit in WParam
is set.
Upvotes: 1