Cita:
Empezado por newtron
Hola.
Yo uso este código en el FormKeyDown y no tengo ningún problema:
Código Delphi [-]
procedure Formulario.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
case Key of
VK_UP: begin
SelectNext(ActiveControl, False, True);
Key := 0;
end;
VK_DOWN: begin
SelectNext(ActiveControl, True, True);
Key := 0;
end;
end;
Saludos
|
De funcionar si funciona, pero me parece curioso que en el primer toque de tecla (Arriba o Abajo) el foco se pierde cuando se deshabilita un edit
chequea esto y miralo, te daras cuenta que presionas la tecla hacia abajo, los edits 2,3,4 se deshabilitan y el foco se pierde
Código Delphi
[-]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
edt4: TEdit;
edt5: TEdit;
edt6: TEdit;
procedure edt1Exit(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.edt1Exit(Sender: TObject);
begin
edt2.Enabled := edt1.Text = '2';
edt3.Enabled := edt1.Text = '2';
edt4.Enabled := edt1.Text = '3';
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_UP: begin
SelectNext(ActiveControl, False, True);
Key := 0;
end;
VK_DOWN: begin
SelectNext(ActiveControl, True, True);
Key := 0;
end;
end;
end;
end.