组合键(ctrl + v + c ...)用于OnKeyDown [英] Combine Key (ctrl+v +c ...) for OnKeyDown
本文介绍了组合键(ctrl + v + c ...)用于OnKeyDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能告诉我如何编写组合键(如ctlr + v)的代码吗?
例如:
Can you tell me how to write code for combine key like ctlr + v.
For example:
OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(nChar == VK_DELETE) //this is ok
//do something
//but if we press control + v how to process it
if(nChar == VK_CONTROL // +, &, | 0x56
我尝试了GetKeyState和GetASyncKeyState,但结果不好
i tried GetKeyState and GetASyncKeyState but the result is not good
if(nChar == 0x56)
{
if((GetAsyncKeyState(VK_CONTROL) & 0x8000) == 0)
{
MessageBox(_T("test thu"));
}
}
我用Google搜索了这是我的问题,但找不到任何有用的方法.
请帮帮我!
This is my problem, i googled, but cant find anything helpful.
pls, help me out!
推荐答案
在WM_KEYDOWN消息中,您应该使用GetKeyState()
.GetAsyncKeyState()
用于WM_KEYDOWN处理程序外部的代码.
Win32:
During a WM_KEYDOWN message you should useGetKeyState()
.GetAsyncKeyState()
is for code outside a WM_KEYDOWN handler.
Win32:
case WM_KEYDOWN:
if (wParam == 'V')
{
if (GetKeyState(VK_CONTROL)<0)
MessageBoxA(hWnd, "TEXT", "CAPTION", MB_OK);
}
您的代码经过修改:
Your code with modifications:
if(nChar == 'V')
{
// you could also say "if (GetKeyState(VK_CONTROL) & 0x8000)"
if (GetKeyState(VK_CONTROL) < 0)
MessageBox(_T("test thu"));
}
感谢您的帮助.特别是nv3,pasztorpisti
Thank you for helping me. Especially nv3, pasztorpisti
这篇关于组合键(ctrl + v + c ...)用于OnKeyDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文