The Windows-based applications do not make explicit function calls to acquire input. They wait for the system to pass the input to them. The system passes input to the different windows in the application. Each window has a function, the window process, which is called by the system when it has input for the window. The window process processes the input and returns control to the system. The system passes the input to a window procedure in the form of messages.
The Messages are generated by both the system and applications. The system produces a message for each and every input event - for illustration, when the user types, moves the mouse or clicks a control like a list box. The system also produces messages in response to changes in the system brought about by an application, like when an application resizes one of its windows. An application can produce messages to direct its own windows to perform the tasks or to communicate with windows in other applications.
Whenever a window procedure receives a message, it uses a message identifier to conclude how to process the message. The message identifiers WM_PAINT tell the window procedure that the window's client region has changed and should be repainted. The WM is for common window messages.