回应只有第一个WM_KEYDOWN通知? [英] Respond to only the first WM_KEYDOWN notification?

查看:171
本文介绍了回应只有第一个WM_KEYDOWN通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何Win32应用程序,只在第一WM_KEYDOWN通知的回复? MSDN文档30位声称指定previous国家重点,其值为1,如果键被按下发送消息前,或者是零,如果关键就到了。但30位始终为0在我的WndProc。

How can a Win32 application respond to only the first WM_KEYDOWN notification? The MSDN docs claim bit 30 "Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up." but bit 30 is always 0 in my WndProc.

case WM_KEYDOWN:
    // ToDo - stop multiple notifications for repeating keys
    printf("WM_KEYDOWN %i %i", wParam, lParam & 30);
	return 0;

lParam的&安培; 30 错误的方式来问这个?我在做别的事情了?

Is lParam & 30 the wrong way to ask for this? Am I doing something else wrong?

推荐答案

要获得30位,你需要这样的:

To get bit 30, you need this:

(lParam & 0x40000000)

另一种方法是使用0-15位,以获得重复计数

An alternative would be to use bits 0-15 to get the repeat count:

int repeatCount = (lParam & 0xffff)

和只能做任何事情,如果重复次数为0(或可能1,我不知道第一条消息是否得到0或1重复次数,并从文档不清晰)

and only do anything if the repeat count is 0 (or possibly 1; I'm not sure whether the first message gets a repeat count of 0 or 1, and it's not clear from the documentation).

这篇关于回应只有第一个WM_KEYDOWN通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆