A: Assign a procedure to the screen.OnActiveControlChange event.
unit Killer2;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure DoActiveControl(Sender: TObject);
procedure FormClose(Sender: TObject; var Action:
TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
OldControl: TComponent;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
screen.OnActiveControlChange := DoActiveControl;
end;
procedure TForm1.DoActiveControl(Sender: TObject);
begin
{This goes first in case the active control is not a TEdit.}
if assigned(OldControl) then
begin
(OldControl as TEdit).color := clWhite;
(OldControl as TEdit).font.color := clBlack;
end;
if activeControl is TEdit then
begin
(activeControl as TEdit).color := clNavy;
(activeControl as TEdit).font.color := clYellow;
OldControl := activeControl as TEdit;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
screen.OnActiveControlChange := nil; {prevents a GPFault}
end;
end.