vc中,如何判断键盘没有按键按下?

hzsszmy 2010-04-29 04:26:56
在c中,这个很好办,察看bioskey即可,

但是在vc中,如何判断键盘没有按键按下?
...全文
749 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
向立天 2010-05-07
  • 打赏
  • 举报
回复
您好
我是本版版主
此帖已多日无人关注
请您及时结帖
如您认为问题没有解决可按无满意结帖处理
另外本版设置了疑难问题汇总帖
并已在版面置顶
相关规定其帖子中有说明
您可以根据规定提交您帖子的链接
如您目前不想结帖只需回帖说明
我们会删除此结帖通知

见此回复三日内无回应
我们将强制结帖
相关规定详见界面界面版关于版主结帖工作的具体办法
尹成 2010-04-29
  • 打赏
  • 举报
回复
onMouseMove中判断WM_KEYDOWN 和 WM_SYSKEYDOWN
不过如果你的mouse不动得时候,就不会进行判断
zwfgdlc 2010-04-29
  • 打赏
  • 举报
回复

SHORT GetKeyState(int nVirtKey);


Parameters

nVirtKey
[in] Specifies a virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code.
If a non-English keyboard layout is used, virtual keys with values in the range ASCII A through Z and 0 through 9 are used to specify most of the character keys. For example, for the German keyboard layout, the virtual key of value ASCII O (0x4F) refers to the "o" key, whereas VK_OEM_1 refers to the "o with umlaut" key.

Return Value

The return value specifies the status of the specified virtual key, as follows:

If the high-order bit is 1, the key is down; otherwise, it is up.
If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.

xladykiller 2010-04-29
  • 打赏
  • 举报
回复
那就要onMouseMove中判断WM_KEYDOWN 和 WM_SYSKEYDOWN
不过如果你的mouse不动得时候,就不会进行判断
Snovate 2010-04-29
  • 打赏
  • 举报
回复
onMouseMove?那就在onMouseDown里设一个标志位改变其值,然后在onMouseMove里判别就OK了吧
hzsszmy 2010-04-29
  • 打赏
  • 举报
回复

我希望在onMouseMove(...)函数中,检测检测键盘状态,码将安出?
Eleven 2010-04-29
  • 打赏
  • 举报
回复
WM_KEYDOWN 和 WM_SYSKEYDOWN都要判断
Snovate 2010-04-29
  • 打赏
  • 举报
回复
先在类向导里加:PreTranslateMessage
pMsg->message==WM_KeyDown就行了
qhplqhp2004 2010-04-29
  • 打赏
  • 举报
回复
BOOL CExeSecond::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message==WM_KEYDOWN)//键盘按下,!= 没按下就相反
{
//处理函数
}

return CDialog::PreTranslateMessage(pMsg);
}

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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