onchar

王朝百科·作者佚名  2011-02-18
窄屏简体版  字體: |||超大  

函数原型:

CWnd::OnCharafx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );

afx_msg没有具体含义。只是为了方便系统找到消息映射函数。

参数意义:define UINT unsigned int 无符号整数

UINT nChar:键盘的字符码值。

UINT nRepCnt 击键的次数

nFlags 包含扫描码,转换码等。

意义如下图所示:

Value

Meaning

0-15

Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user holding down the key.

16-23

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

24

Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.

25-28

Used internally by Windows.

29

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

30

Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.

31

Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed.

参数: (中文)nChar 包含了键的字符代码值。 nRepCnt 包含了重复计数,当用户按下键时重复的击键数目。 nFlags 包含了扫描码,键暂态码,以前的键状态以及上下文代码,如下面的列表所示:

含义

0--15

指定了重复计数。其值是用户按下键时重复的击键数目

16--23

指定了扫描码。其值依赖于原始设备制造商(OEM)

24

指明该键是否是扩展键,如增强的101或102键盘上右边的ALT或CTRL键如果它是个扩展键,则该值为1;否则,值为0

25--28

Windows内部使用

29

指定了上下文代码。如果按键时ALT键是按下的,则该值为1;否则,值为0

30

指定了以前的键状态。如果在发送消息前键是按下的,则值为1;如果键是弹起的,则值为0

31

指定了键的暂态。如果该键正被放开,则值为1,如果键正被按下,则该值为0

说明:

当击键被转换为非系统字符时,框架调用这个成员函数。这个函数是在OnKeyUp成员函数之前,OnKeyDown成员之后调用的。OnChar包含了被按下或放开的键值。

由于按键和产生的OnChar调用不必是一一对应的,因此nFlags中的信息对应用程序通常是没有用的。NFlags中的信息仅对最近在OnChar之前调用的OnKeyUp成员函数或OnKeyDown成员函数有用。

对于IBM增强型101和102键键盘,键盘的主体部分的增强键是右边的ALT和CTRL键;还有数字键盘左侧的INS,DEL,HOME,END,PAGE UP,PAGE DOWN以及箭头键等;以及数字键盘上的斜杠(/)和ENTER键。其它键盘可能会支持nFlags中的扩展键位。

注意:

框架调用这个成员函数以允许你的应用程序处理一个Windows消息。传递给你的成员函数的参数反映了接收到消息时框架接收到的参数。如果你调用了这个函数的基类实现,则该实现将使用最初传递给消息的参数(而不是你提供给这个函数的参数)。

请参阅:WM_CHAR, WM_KEYDOWN, WM_KEYUP

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航