如何获取方向键的按下? 急!

wuxking 2003-10-27 04:58:14
如何获取方向键的按下? 例如我按下 up 要求做 Edit1->SetFocus();
并且对于left right down 分别判断,如何进行?谢谢。
...全文
30 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuxsun 2004-01-08
  • 打赏
  • 举报
回复
利用KeyDown事件 VK_UP VK_DOWN VK_LEFT VK_RIGHT
就可以了。
guanshangming 2003-10-27
  • 打赏
  • 举报
回复
Specifies the control that has focus on the form.

__property Controls::TWidgetControl* ActiveControl = {read
=FActiveControl, write=SetActiveControl, stored=IsForm};

Description

Use ActiveControl to get or set the control that has focus on the form. Only one control can have focus at a given time in an application.

If the form does not have focus, ActiveControl is the control on the form that will receive focus when the form receives focus.

Note: When focus shifts to another control, ActiveControl is updated before the OnExit event occurs.
wuxking 2003-10-27
  • 打赏
  • 举报
回复
qiuafa() :

如果在form上面获取KeyDown, 那么我如何知道当前tab在哪个控件(class)上面?就是哪个对象是得到focus的?谢谢。
我不懂电脑 2003-10-27
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == VK_UP) {
}
}
wuxking 2003-10-27
  • 打赏
  • 举报
回复
我在Edit1 里面按下方向键, 如何让Edit2->SetFocus() ?

不是在Form上面,谢谢!
yayowd 2003-10-27
  • 打赏
  • 举报
回复
设置Form的属性KeyPreview为true;然后处理FormKeyDown事件,就可以在任何时候响应方向键了!
qiuafa 2003-10-27
  • 打赏
  • 举报
回复
void __fastcall TForm1::FormShortCut(TWMKey &Msg, bool &Handled)
{
switch (Msg.CharCode)
{
case VK_UP : Edit1->SetFocus(); break;
case VK_DOWN : break;

}
}
semitone 2003-10-27
  • 打赏
  • 举报
回复
Form中有一个FormKeyDown事件函数,通过实践函数中的参数(WORD &Key)进行判断。

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧