想请教:BC里,如何捕获小键盘数字键1—9啊?新年快乐!
我在BC里,想捕获小键盘的几个数字键,比如按下键1的时候,就跳出个消息框,等等,请问如何来写?万分感谢,最好有一段代码让我看看。
[解决办法]
新年快乐
HHOOK hKeyHook=NULL;
//---------------------------------------
LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam)
{
PKBDLLHOOKSTRUCT pKBHook = (PKBDLLHOOKSTRUCT)lParam;
if(pKBHook-> vkCode==VK_NUMPAD1)
{
ShowMessage( "你按了数字键1 ");
}
return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
hKeyHook=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)HookProc,HInstance,0);
}
//---------------------------------------
__fastcall TForm1::~TForm1()
{
UnhookWindowsHookEx(hKeyHook);
}