Delen via


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:

Flag

Meaning

0-7

Specifies the scan code. The value depends on the original equipment manufacturer (OEM).

8

Specifies 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-12

Used internally by Windows.

13

Specifies the context code. The flag is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0.

14

Specifies 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.

15

Specifies 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.

Note

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