按DEL键竞不发送WM_CHAR消息,而发送WM_KEYDOWN消息,还有消息中的第一个参数是虚拟键值,第二个参数不知干什么的??

yongdu 2000-03-17 03:42:00
...全文
229 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Shania 2000-03-17
  • 打赏
  • 举报
回复
很简单:
WM_CHAR:只接受ASCII码,区分大小写
WM_KEYDOWN:接受VIRTUAL KEY,(include 光标,DEL...),不区分大小写!
第二个参数是一个32位的数,每一位或几位都代表了一些键盘的设置状态:
0-15位:按键延迟的时间
16-23位:指定扫描码,主要和OEM厂商有关
24位:值为1时代表这是一个扩展码(不在标准101,102键盘上的)
25-28位:不用
29位:WM_KEYDOWN时,为0
30位:前一个键的状态(DWON OR UP)
31位:WM_KEYDOWN时,为0
929 2000-03-17
  • 打赏
  • 举报
回复
The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR contains the character code of the key that was pressed.

WM_CHAR是在WM_KEYDOWN以后发生,其间WINDOWS经过TranslateMessage调用,对按键进行了解释。而DEL在解释后,被滤掉了。
在LPARAM中传送lKeyData,代表当消息传送时,这个按键的重复次数(因为WINDOWS消息循环没有实时传递按键消息),扫描码(SCAN CODE),以及扩展键标志。及ALT等键的状态。


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 Reserved; do not use.
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.
Jackzhu 2000-03-17
  • 打赏
  • 举报
回复
Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated 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.
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 Reserved; do not use.
29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
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 always 0 for a WM_KEYDOWN message

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧