All that I've described so far is really just overhead. The window class has been registered, the window has been created, the window has been displayed on the screen, and the program has entered a message loop to retrieve messages from the message queue.
The real action occurs in the window procedure, which Windows programmers commonly call a ”window proc“ (pronounced ”prock“). The window procedure determines what the window displays in its client area and how the window responds to user input.
In HELLOWIN, the window procedure is the function called WndProc. A window procedure can have any name. A Windows program can contain more than one window procedure. A window procedure is always associated with a particular window class that you register by calling RegisterClass. The CreateWindow function creates a window based on a particular window class. More than one window can be created based on the same window class.
A window procedure is always defined like this:
long FAR PASCAL WndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
Note that the four parameters to the window procedure are identical to the first four fields of the MSG structure.
The first parameter is hwnd, the handle to the window receiving the message. This is the same handle returned from the CreateWindow function. For a program like HELLOWIN, which creates only one window, this is the only window handle the program knows about. If a program creates multiple windows based on the same window class (and hence the same window procedure), then hwnd identifies the particular window receiving the message.
The second parameter is a number (specifically, a 16-bit unsigned integer or WORD) that identifies the message. The last two parameters (a WORD called wParam and a 32-bit signed long integer or LONG called lParam) provide more information about the message. These are called ”message parameters.“ What these parameters contain is specific to each type of message.