Processing Character Messages

A window procedure receives a character message when the TranslateMessage function translates a virtual-key code corresponding to a character key. The character messages are WM_CHAR, WM_DEADCHAR, WM_SYSCHAR, and WM_SYSDEADCHAR. A typical window procedure ignores all character messages except WM_CHAR. The TranslateMessage function generates a WM_CHAR message when the user presses any of the following keys.

  • Any character key

  • BACKSPACE

  • ENTER (carriage return)

  • ESC

  • SHIFT+ENTER (linefeed)

  • TAB

When a window procedure receives the WM_CHAR message, it should examine the character code that accompanies the message to determine how to process the character. The character code is in the message's wParam parameter.

The following example shows the window procedure framework that a typical application uses to receive and process character messages.

case WM_CHAR:

switch (wParam) {

case 0x08:

.

. /* Process a backspace. */

.

break;

case 0x0A:

.

. /* Process a linefeed. */

.

break;

case 0x1B:

.

. /* Process an escape. */

.

break;

case 0x09:

.

. /* Process a tab. */

.

break;

case 0x0D:

.

. /* Process a carriage return. */

.

break;

default:

.

. /* Process displayable characters. */

.

break;

}

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database