Chapter 6 Messages Directory

Microsoft Windows communicates with applications through formatted win-dow messages. These messages are sent to an application's window function for processing.

Some messages return values that contain information about the success of the message or other data needed by an application. To obtain the return value, the application must call SendMessage to send the message to a window. This function does not return until the message has been processed. If the application does not require the return value of the message, it may call PostMessage to send the message. This function places a message in a window's application queue and then returns immediately. If a message does not have a return value, then the application may use either function to send the message, unless indicated otherwise in the message description.

A message consists of three parts: a message number, a word parameter, and a long parameter. Message numbers are identified by predefined message names. The message names begin with letters that suggest the meaning or origin of the message. The word and long parameters, named wParam and lParam respectively, contain values that depend on the message number.

The lParam parameter often contains more than one type of information. For example, the high-order word may contain a handle to a window and the low-order word may contain an integer value. The HIWORD and LOWORD utility macros can be used to extract the high- and low-order words of the lParam parameter. The HIBYTE and LOBYTE utility macros can also be used with HIWORD and LOWORD to access any of the bytes. Casting can also be used.

There are four ranges of message numbers, as shown in the following list:

Range Meaning  
0 to WM_USER – 1 Reserved for use by Windows.  
WM_USER to 0x7FFF Integer messages for use by applications.  
0x8000 to 0xBFFF Reserved for use by Windows.  
0xC000 to 0xFFFF String messages for use by applications.  

Message numbers in the first range (0 to WM_USER – 1) are defined by Windows. Values in this range that are not explicitly defined are reserved for future use by Windows. This chapter describes messages in this range.

Message numbers in the second range (WM_USER to 7FFF) can be defined and used by an application to send messages within the application. These messages should not be sent to other applications unless the applications have been designed to exchange messages and to attach the same meaning to the message numbers.

Message numbers in the third range (8000 to BFFF) are reserved for future use by Windows.

Message numbers in the fourth range (C000 to FFFF) are defined at run time when an application calls the RegisterWindowMessage function to obtain a message number for a string. All applications that register the identical string can use the associated message number for exchanging messages with each other. The actual message number, however, is not a constant and cannot be assumed to be the same in different window sessions.

This chapter lists messages in alphabetical order. For more information about messages, see Chapter 5, “Messages Overview.”