/* * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. * Used only as parameters to GetAsyncKeyState() and GetKeyState(). * No other API or message will distinguish left and right keys in this way. */ #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 #define VK_RCONTROL 0xA3 #define VK_LMENU 0xA4 #define VK_RMENU 0xA5
Parameters nVirtKey Value of wParam. Specifies the virtual-key code of the nonsystem key. lKeyData 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. 看完了 我快要晕了。**号那里!!!!!!!!!!!!!!!!!!! 我马上去做个 例子!! 你等等!!!
非常感谢 Robert2001 的回答以及您的代码! 最近没有回复,让您和大家久等了,非常抱歉! 首先我要告诉您,在您的帮助我已经完成了,就是这个方法,我在MSDN中看到了,但就是由于该死的MS和它的MSDN,让我上当了,它在两个不同的地方,说法不太一样,我一开始找对地方了,和您说的完成一样,但后来我又在里面找到了另一个说法: Value Description 0–15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's 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 a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0. ------------------------------------------------------- 25–28 Reserved. 29 Specifies the context code. The value is 1 if the alt key is down; otherwise, it is 0. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. 31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released. 它这里没有提左右键的事情,而是关于功能键和小键盘的键,另外我的代码也有一些问题,所以就以为这种方法不正确呢! 现在看到您的回答,我有重新翻阅了一下MSDN,整理整理代码,最后已经完成了! 谢谢了! 现在开始加分!
你可以使用语句: iState=GetKeyState(VK_LCONTROL); /* 或VR_RCONTROL */
然后你在看 iState 的值是不是○〔在Windows9X下〕!
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
*/
#define VK_LSHIFT 0xA0
#define VK_RSHIFT 0xA1
#define VK_LCONTROL 0xA2
#define VK_RCONTROL 0xA3
#define VK_LMENU 0xA4
#define VK_RMENU 0xA5
你可以使用语句: iState=GetKeyState(VK_LCONTROL); /* 或VR_RCONTROL */
然后你再看 iState 的值是不是○〔在Windows9X下〕
我害怕VC忽略这些定义,还专门直接在源文件中重新定义了一下,也不行!
高手们,在下诚心请教各位有何高见!
大哥你问的 问题怎么这么变态
我刚试了一下! 我这里也不行! 为什么呢! MSDN 写的是可以的啊!! 哎 晕菜!!
你等等我在问 问别人!
有结果吗?
难道windows下有所不同??
MSDN 上讲的太笼统了。
我觉得应该可以! 有些游戏 模拟器 就能区分 左右。
WM_KEYDOWN
nVirtKey = (int) wParam; // virtual-key code
lKeyData = lParam; // key data
Parameters
nVirtKey
Value of wParam. Specifies the virtual-key code of the nonsystem key.
lKeyData
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.
看完了 我快要晕了。**号那里!!!!!!!!!!!!!!!!!!!
我马上去做个 例子!! 你等等!!!
case WM_KEYDOWN:
switch(wParam)
{
case VK_CONTROL:
x= pow(2,24);
if(lParam & x)
{
MessageBox(NULL,"","",NULL);
}
break;
}
break;
如果是右边的Ctrl 按下的话 就会弹出 MessageBox 左边的没有/ 但是关于 GetKeyState(VK_RSHIFT); 还没有搞明白。
最近没有回复,让您和大家久等了,非常抱歉!
首先我要告诉您,在您的帮助我已经完成了,就是这个方法,我在MSDN中看到了,但就是由于该死的MS和它的MSDN,让我上当了,它在两个不同的地方,说法不太一样,我一开始找对地方了,和您说的完成一样,但后来我又在里面找到了另一个说法:
Value Description
0–15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's 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 a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
-------------------------------------------------------
25–28 Reserved.
29 Specifies the context code. The value is 1 if the alt key is down; otherwise, it is 0.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.
31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released. 它这里没有提左右键的事情,而是关于功能键和小键盘的键,另外我的代码也有一些问题,所以就以为这种方法不正确呢!
现在看到您的回答,我有重新翻阅了一下MSDN,整理整理代码,最后已经完成了!
谢谢了!
现在开始加分!
我在DOS很早就已经实现过了!
你可以到下面的地址 http://chinahlsoft.myetang.com/Software/zbrj-d.htm 去下载“华龙编辑伴侣[DOS版] V5.1”软件,它就是我写的一个早期作品,就可以在DOS下分辨出Ctrl,Alt,Shift的左右键来!
另外需要注意至少要下载一个数据文件悠!