A window procedure is a function that takes 4 arguments and returns a 32-bit pointer. The arguments of a window procedure consist of a window handle, a ULONG message identifier, and two arguments, called message parameters, that are declared with the MPARAM data type. The system defines an MPARAM as a 32-bit pointer to a VOID data type (a generic pointer). The message parameters actually might contain any of the standard data types. The message parameters are interpreted differently,depending on the value of the message identifier. The operating system includes several macros that enable the application to cast the information from the MPARAM values into the actual data type. SHORT1FROMMP, for example, extracts a 16-bit value from a 32-bit MPARAM. The window-procedure arguments are described in the following table:
┌───────────────┬─────────────────────────────────────────────┐ │Argument │Description │ ├───────────────┼─────────────────────────────────────────────┤ │hwnd │Handle of the window receiving the message. │ ├───────────────┼─────────────────────────────────────────────┤ │msg │Message identifier. The message will │ │ │correspond to one of the predefined constants│ │ │(for example, WM_CREATE) defined in the │ │ │system include files or be an │ │ │application-defined message identifier. The │ │ │value of an application-defined message │ │ │identifier must be greater than the value of │ │ │WM_USER, and less than or equal to 0xffff. │ ├───────────────┼─────────────────────────────────────────────┤ │mp1,mp2 │Message parameters. Their interpretation │ │ │depends on the particular message. │ └───────────────┴─────────────────────────────────────────────┘
The return value of a window procedure is defined as an MRESULT data type. The interpretation of the return value depends on the particular message. Consult the description of each message to determine the appropriate return value.