Ver Mensaje Individual
  #9  
Antiguo 19-05-2017
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Reputación: 20
oscarac Va por buen camino
Cita:
Empezado por newtron Ver Mensaje
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
    { Private declarations }
  public
    { Public declarations }
  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.
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita