Previous: 6.1. Writing Win32 GUI Applications To the Table of Contents Next: 6.3. Designing a Window Procedure
6.1. Writing Win32 GUI Applications Table of Contents 6.3. Designing a Window Procedure

- 6.2. -
Table of Contents
6. Win32 Programming
6.2. Structure of Window Procedure


6.2. Structure of Window Procedure


A window procedure is a function that has four parameters and returns a 32-bit signed value (Longint). The parameters consist of a window handle, a UINT message identifier, and two message parameters declared with the WParam and LParam data types. For more information, see the WIN32.HLP.

Message parameters often contain information in both their low-order and high-order words. The Microsoft® Win32® application programming interface (API) includes several macros an application can use to extract information from the message parameters. The LOWORD function, for example, extracts the low-order word (bits 0 through 15) from a message parameter. Other functions include HIWORD, LOBYTE, and HIBYTE.

The interpretation of the return value depends on the particular message. Consult the description of each message to determine the appropriate return value.

Because it is possible to call a window procedure recursively, it is important to minimize the number of local variables that it uses. When processing individual messages, an application should call functions outside the window procedure to avoid excessive use of local variables, possibly causing the stack to overflow during deep recursion.


Previous: 6.1. Writing Win32 GUI Applications To the Table of Contents Next: 6.3. Designing a Window Procedure
6.1. Writing Win32 GUI Applications Table of Contents 6.3. Designing a Window Procedure

- 6.2. -