unit EditSint;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TEditSint = class(TEdit)
private
{ Private declarations }
FColorSint:TColor;
FColorDefoult:TColor;
FList:TStrings;
protected
{ Protected declarations }
procedure Change; override;
procedure SetList(value:TStrings);
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property ColorSint:TColor read FColorSint write FColorSint;//цвет подсветки
property ColorDefoult:TColor read FColorDefoult write FColorDefoult;//цвет по умолчанию
property List:TStrings read FList write SetList;//список выражений, которые должны подсвечиваться
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TEditSint]);
end;
constructor TEditSint.Create(AOwner: TComponent);
begin
inherited create(AOwner);
FList:=TStringList.Create;
FColorSint:=clBlack;
FColorDefoult:=clBlack;
end;
destructor TEditSint.Destroy;
begin
inherited;
FList.Free;
end;
procedure TEditSint.Change;
var
i:Integer;
b:boolean;
begin
inherited;
If FList.Count=0 then
begin
Self.Font.Color:=FColorDefoult;
exit;
end;
b:=False;
For i:=0 to FList.Count-1 do
begin
If Self.Text=FList.Strings[i] then
begin
b:=True;
Self.Font.Color:=FColorSint;
break;
end;
end;
If not b then
Self.Font.Color:=FColorDefoult;
end;
procedure TEditSint.SetList(value:TStrings);
begin
TStringList(FList).Clear;
TStringList(FList).Assign(value);
end;
end.