键盘截取事件,一点响应也没有,怎么回事?
代码如下:
void __fastcall TmainForm::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==VK_RETURN)
return;
if ((Key==VK_DOWN) || (Key==13) )
{
SelectNext(ActiveControl,True,True);
}
if( Key==VK_UP)
{
SelectNext(ActiveControl,False,True);
Key=0;
}
}
//---------------------------------------
void __fastcall TmainForm::FormKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
{
SendMessage(this -> Handle,WM_NEXTDLGCTL,0,0);
Key=0;
}
}
执行之后按回车键不跳格,没反应,请大家帮忙~~~~~~~
[解决办法]
1.SelectNext(ActiveControl,False,True);
下一个默认的活动且能接受焦点的组件获得焦点, 然后Key值还原为空白(ASCII码值为零).
2.SendMessage(this- >Handle,WM_NEXTDLGCTL,0,0);
Key=0;
发送消息给主窗体, 然后Key值还原为空白.