如何确定键盘上同时按下了两个健,
如shift + UP ,shift + c ,
onKeyDown好像不行
因为按下第二个健以后第一个建的事件就终止了
如shift + UP ,shift + c ,
onKeyDown好像不行
因为按下第二个健以后第一个建的事件就终止了
解决方案 »
- win xp不能构造TCP包
- 请问:关于定制通用对话框?谢谢
- 请教jiangsheng(蒋晟.MSMVP2004Jan):为什么我的程序停在HRESULT hr = g_lpHTMLDocument2->get_all(&pForm);不动?
- 这个程度一般可以找到怎样的工作?
- 谁有SDK的并口通信程序?
- ado的版本
- 用printf输出时如何才能不打印小数点前的0?
- Dlg的窗口,为什么EDIT里一按回车就结束?
- 可以用智能指针auto_ptr指向数组吗?
- C++的题目 帮忙做下
- 如何手工引发 onCtlColor?
- 新建如果选WIN32那个选项,WINDOW是用CREATEWINDOWEX创建的,那么怎么向WINDOW上放EDIT等控件啊。请问大家都是怎么处理的?我是菜鸟,帮
当按shift键OnKeyDown时将bIsShiftDown=true;
相反OnKeyUp时bIsShiftDown=false;
然后在按别的键时判断上面的值就知道是否为按下状态了。
使用函数GetKeyState()或GetKeyboardState()。MSDN有详细说明。
if(::GetKeyState(VK_LSHIFT)<0)
MessageBox("shift key is down");
GetKeyState()或GetKeyboardState()。
CWnd::OnChar
afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );ParametersnCharContains the character code value of the key.nRepCntContains the repeat count, the number of times the keystroke is repeated when user holds down the key.nFlagsContains the scan code, key-transition code, previous key state, and context code, as shown in the following list: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.
{
BOOL bShiftDown=::GetKeyState(VK_SHIFT)&0x8000;// if (pMsg->message==WM_KEYDOWN && !bShiftDown) {
// pMsg->hwnd=NULL; return TRUE;} return CFormView::PreTranslateMessage(pMsg);
}