试试,[
]
procedure TForm.KeyDown(var Key: Word; Shift: TShiftState);
var
C: TControlCanvas;
MemoLines: Integer;
TempList: TList;
begin
inherited KeyDown(Key, Shift);
if ActiveControl is TCustomComboBox then
if SendMessage(ActiveControl.Handle, CB_GETDROPPEDSTATE, 0, 0) <> 0 then {drowDown}
Exit;
if Key = VK_RETURN then
begin
if ActiveControl is TCustomMemo then
begin
C := TControlCanvas.Create;
C.Control := ActiveControl;
C.Font := TMemo(ActiveControl).Font;
MemoLines := ActiveControl.ClientHeight div (C.Textheight('XBP') + 1); {1: between line }
C.Free;
if MemoLines > 1 then Exit; {More than One Lines can visible only.}
end;
if (ActiveControl<>Nil) and (ActiveControl.parent.ClassType = BTPanel) then
begin
try
TempList := TList.Create;
ActiveControl.Parent.GetTabOrderList(TempList);
if ActiveControl.TabOrder = TempList.count - 1 then
ActiveControl.parent.SetFocus;
finally
TempList.Free;
end;
end;
Key := VK_TAB;
end;
end;