Why should I use WndProc when I have form events?

I have a basic question about using WndProcforms in my application. I want to know what method use WndProcis when I have forms available. When do I need to create my own posts? MSDN reports that it is used only for processing Windows messages.

+5
source share
2 answers

WndProc is how WinForms provides a wrapper around Win32 window messages with an easier to use and understand .NET level.

It usually works as follows. Take the example Windows message WM_LBUTTONDOWN. Windows.Forms.Control.WndProc will intercept this message and extract the relevant information from the WPARAM and LPARAM messages. Then it calls the protected virtual method OnMouseDown with the corresponding information, beautifully packed in MouseEventArgs. The implementation then completes the MouseDown event at the end of its processing.

Thus, accessing the OnXXXX / XXXX method set is much simpler than intercepting Windows messages directly.

, Windows, , WinForms? WndProc . - , , . . , , , .

+4

.NET - Win32. 100% , Windows.

.

, - , Stack Exchange .

+2

All Articles