Hola Oscar.
Ajustando el bosquejo anterior para su uso con los edits, quedaría:
Código Delphi
[-]
...
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
...
private
procedure ActiveControlChange(Sender: TObject);
end;
...
implementation
uses TypInfo;
var
PrevFocusCtrl: TWinControl;
MaxTO: Integer = -2;
procedure TForm1.ActiveControlChange(Sender: TObject);
begin
PrevFocusCtrl:= Screen.ActiveControl;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i, tbo:integer;
PInfo: PPropInfo;
begin
for i:= 0 to ControlCount-1 do
if Assigned(GetPropInfo(Controls[i].ClassInfo, 'TabOrder')) then
begin
tbo:= GetOrdProp(Controls[i], 'TabOrder');
if tbo > MaxTO then MaxTO:= tbo;
if Controls[i].ClassType = TEdit then
TEdit(Controls[i]).OnExit:= EditsExit;
end;
PrevFocusCtrl:= Screen.ActiveControl;
Screen.OnActiveControlChange:= ActiveControlChange;
end;
procedure TForm1.EditsExit(Sender: TObject);
begin
if (ActiveControl.TabOrder > PrevFocusCtrl.TabOrder) then
begin
try
StrToFloat(TEdit(PrevFocusCtrl).Text);
except
PrevFocusCtrl.SetFocus;
MessageBox(0,PChar('Error validando '+PrevFocusCtrl.Name),'',MB_ICONERROR);
end;
end;
end;
Excepto que no tengas en mente permitir el uso del mouse en la pantalla de ingreso... En cuyo caso bastaría con evaluar las combinaciones de teclas que indicas en tu mensaje.
Saludos