Eigentlich brauchst Du dann nur einen Button, man muss nur wissen welches Edit zuletzt den Focus hatte.
Hab da mal was ausprobiert
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
Active, Previous : TWinControl;
public
{ Public-Deklarationen }
procedure ControlChanged(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ControlChanged(Sender: TObject);
begin
Previous := Active;
Active := Form1.ActiveControl;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.OnActiveControlChange := ControlChanged;
end;
procedure TForm1.Button1Click(Sender: TObject) ;
begin
if TEdit(Previous) = Edit1
then ShowMessage('
Edit1 hatte den Focus');
if TEdit(Previous) = Edit2
then ShowMessage('
Edit2 hatte den Focus');
if TEdit(Previous) = Edit3
then ShowMessage('
Edit3 hatte den Focus');
end;
end.
Vergiss nicht ControlChanged freizugeben.
Uwe