CWnd::OnUniChar

The framework calls this member function when a key is pressed. That is, the current window has the keyboard focus and a WM_KEYDOWN message is translated by the TranslateMessage function.

afx_msg void OnUniChar(
    UINT nChar, 
    UINT nRepCnt, 
    UINT nFlags
);

Parameters

Parameter

Description

[in] nChar

Specifies the character code of the pressed key.

[in] nRepCnt

Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.

[in] nFlags

Flags that specify the scan code, extended key, context code, previous key state, and transition state, as shown in the following table:

FlagMeaning
0-7Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
8Specifies an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101 or 102-key keyboard. The flag is 1 if the key is an extended key; otherwise, it is 0.
9-12Used internally by Windows.
13Specifies the context code. The flag is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0.
14Specifies the previous key state. The flag is 1 if the key is down before the message is sent, or 0 if the key is up.
15Specifies the transition state. The flag is 1 if the key is being released, or 0 if the key is being pressed.

Remarks

This method receives the WM_UNICHAR notification, which is described in the Windows SDK. The WM_UNICHAR message is designed to send or post Unicode characters to ANSI windows. It is equivalent to the WM_CHAR message, but uses Unicode Transformation Format-32 encoding (UTF-32), whereas the WM_CHAR message uses UTF-16.

Notes

This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

Requirements

Header: afxwin.h

This method is supported in Windows Vista and later.

Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.

See Also

Reference

CWnd Class

Hierarchy Chart

WM_UNICHAR

WM_CHAR

CWnd::OnKeyDown

Concepts

CWnd Members