vb>>>>>delphi 的問題(0分)

  • 主题发起人 主题发起人 hanson_hao
  • 开始时间 开始时间
H

hanson_hao

Unregistered / Unconfirmed
GUEST, unregistred user!
我是學vb 的, 目前正在學習Delphi ,遇到一個問題,就是想在 tedit 框中設定 ENTER 的時候就 產生一個 TAB 事件,也就是將焦點放到下一個物件上,,,,應該如何實現??
唉,,在vb 中 只要 sendkey 就能實現.....應該不會要我在Delphi 每個物件的keypress 事件中都設定 ...setfouce.........O_O[:(!]
 
在onkeypress事件中写:

if key=VK_RETURN then key:=VK_TAB;
 
25、回车替Tab下移控件


需要用回车键代替TAB键下移一个控件时,把KeyPress设为True,加入下列代码拦截击键:
Procedure TForm1.FormKeyPress(Sender:Tobject;Var Key:Char);
Begin
 if key=#13 then { 判断是按执行键}
 if not (ActiveControl is TDbgrid) Then
 Begin { 不是在TDbgrid控件内}
  key:=#0;
  perform(WM_NEXTDLGCTL,0,0);{移动到下一个控件}
 end else
 if (ActiveControl is TDbgrid) Then{是在 TDbgrid 控件内}
 begin
  With TDbgrid(ActiveControl) Do
  if Selectedindex<(FieldCount-1) then
  Selectedindex:=Selectedindex+1{ 移动到下一字段}
  else Selectedindex:=0;
 end;
End;
 
procedure TSys_FLogON.NextFocus(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_RETURN:
begin
SelectNext(Sender as TWinControl, True, True);
Key:=0;
end;
VK_UP:
begin
SelectNext(Sender as TWinControl, False, True);
Key:=0;
end;
VK_DOWN:
begin
SelectNext(Sender as TWinControl, True, True);
Key:=0;
end;
end;
end;
 
后退
顶部