WM_INPUTLANGCHANGE message

Sent to the topmost affected window after an application's input language has been changed. You should make any application-specific settings and pass the message to the DefWindowProc function, which passes the message to all first-level child windows. These child windows can pass the message to DefWindowProc to have it pass the message to their child windows, and so on.

A window receives this message through its WindowProc function.

#define WM_INPUTLANGCHANGE              0x0051

Parameters

wParam

Type: **WPARAM**

The BYTE font character set for the input language.

If you register the window class using the Unicode version of RegisterClassEx (RegisterClassExW), you typically do not need to use this value. If you register the window class using the ANSI version of RegisterClassEx (RegisterClassExA), this value can be used to create fonts that can correctly display the character set. See iCharSet parameter of the CreateFont function for a list of possible values.

lParam

Type: **LPARAM**

The HKL input locale identifier.

The low word contains a Language Identifier for the input language. The high word contains a device handle.

Return value

Type: LRESULT

An application should return nonzero if it processes this message.

Remarks

You can retrieve the BCP 47 locale name from the language identifier by calling the LCIDToLocaleName function. Once you have the locale name, you can then use modern locale functions to extract additional locale information.

case WM_INPUTLANGCHANGE:
{
    HKL hkl = (HKL)lParam;
    // LANGIDs are deprecated. Use BCP 47 locale names where possible.
    LANGID langId = LOWORD(HandleToUlong(hkl));

    WCHAR localeName[LOCALE_NAME_MAX_LENGTH];
    LCIDToLocaleName(MAKELCID(langId, SORT_DEFAULT), localeName, LOCALE_NAME_MAX_LENGTH, 0);

    // Get the ISO abbreviated language name (for example, "eng").
    WCHAR lang[9];
    GetLocaleInfoEx(localeName, LOCALE_SISO639LANGNAME2, lang, 9);
    
    // Get the keyboard layout identifier (for example, "00020409" for United States-International keyboard layout)
    WCHAR keyboardLayoutId[KL_NAMELENGTH];
    GetKeyboardLayoutNameW(keyboardLayoutId);
}

To get the name of the currently active keyboard layout, call the GetKeyboardLayoutName. For more information, see Languages, Locales, and Keyboard Layouts.

For a list of the input layouts that are supplied with Windows, see Keyboard Identifiers and Input Method Editors for Windows.

Input Method Editor (IME) profile changes may not be notified with WM_INPUTLANGCHANGE. You can use ITfActiveLanguageProfileNotifySink from the Text Services Framework to handle active language or text service changes.

Starting with Windows 8

Some input layouts may not have assigned language identifiers and could be reported as transient language identifiers, such as LOCALE_TRANSIENT_KEYBOARD1 (0x2000) or LOCALE_TRANSIENT_KEYBOARD2 (0x2400), in the low word of LPARAM.

As these transient language identifiers can be re-assigned by the system at any time (such as when the user changes their Language Profile), and can identify a different locale based on the user and/or system, they cannot be considered durable identifiers. See The deprecation of LCIDs for more info.

Retrieve the language associated with the current keyboard layout or input method by calling Windows.Globalization.Language.CurrentInputMethodLanguageTag. If your app passes language tags from CurrentInputMethodLanguageTag to any National Language Support functions, it must first convert the tags with ResolveLocaleName. If you want to be notified about a language change in a UWP app, handle the Windows.UI.Text.Core.CoreTextServicesManager.InputLanguageChanged event.

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Winuser.h (include Windows.h)

See also

Reference

Conceptual