WindowProc: Difference between revisions
Replace dead external links |
m formatting fix |
||
Line 4: | Line 4: | ||
The window procedure is responsible for handling all messages that are sent to a window. The [[function prototype]] of WindowProc is given by: |
The window procedure is responsible for handling all messages that are sent to a window. The [[function prototype]] of WindowProc is given by: |
||
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
||
<code>hwnd</code> is a handle to the window to which the message was sent and <code>uMsg</code> identifies the actual message. <code>wParam</code> and <code>lParam</code> are parameters whose meaning depends on the message. An application should identify the message and take the required action. |
|||
==Default processing== |
==Default processing== |
Revision as of 02:04, 29 November 2022
In Win32 application programming, WindowProc (or window procedure) is a user-defined callback function that processes messages sent to a window. This function is specified when an application registers its window class and can be named anything (not necessarily WindowProc).
Message handling
The window procedure is responsible for handling all messages that are sent to a window. The function prototype of WindowProc is given by:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
hwnd
is a handle to the window to which the message was sent and uMsg
identifies the actual message. wParam
and lParam
are parameters whose meaning depends on the message. An application should identify the message and take the required action.
Default processing
Hundreds of different messages are produced as a result of various events taking place in the system, and typically, an application processes only a small fraction of these messages. In order to ensure that all messages are processed, Windows provides a default window procedure called DefWindowProc that provides default processing for messages that the application itself does not process.
An application usually calls DefWindowProc at the end of its own WindowProc function so that whatever messages it has not processed are passed on to the default procedure.