Short Answer: It goes back to listening for more events.
Detailed Answer:
Under the hood, everything in Windows runs on top of the Win32 API. The Win32 API has at least 2 functions that all programs run. The window procedure is one and that is where our event messages get processed. The other one is called the message loop and it looks similar to this:
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
The message loop is the heart of all event-based Windows programs. GetMessage()
gets a message from your application's message queue. Any time the user moves the mouse, types on the keyboard, clicks on your window's menu, or does any number of other things, messages are generated by the system and entered into your program's message queue. By calling GetMessage()
you are requesting the next available message to be removed from the queue and returned to you for processing.
TranslateMessage()
does some additional processing on keyboard events. Finally DispatchMessage()
sends the message out to the window that the message was sent to.