如何让按钮响应 向左和向右按键
void __fastcall TForm1::Button1KeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
if(Key == VK_LEFT)
{
OutputDebugString("left");
}
else if(Key == VK_RIGHT)
{
OutputDebugString("right");
}
}
void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg,
bool &Handled)
{
if (Msg.message == WM_KEYDOWN && Msg.hwnd == Button1->Handle)
{
if (Msg.wParam == VK_LEFT)
{
OutputDebugString("left");
}
else if (Msg.wParam == VK_RIGHT)
{
OutputDebugString("right");
}
}
}