A: Doing a ShowMessage() on the exit of a component confuses the program as to just where the focus is supposed to be. This is a workaround.
Warning: Be careful to avoid infinite loops. You don't want to go to another component that has its own OnExit() routine that calls another one, etc, etc.
unit unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
procedure Edit1Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Edit1Exit(Sender: TObject);
begin
ShowMessage((sender as TEdit).name);
PostMessage(Handle, WM_NextDLGCTL, 0, 0); {next control}
PostMessage(Handle, WM_NextDLGCTL, 1, 0); {previous control}
end;
end.