Prilagodio sam DBEdit kontrolu svojim potrebama.Konkretno,pri fokusu ona poprima boju koju def.korisnik,kao i pri izlazu iz nje.Problem nastaje kada hocu da definisem tip i boju fonta.Tada kompajler prijavljuje gresku.Slican kod sam koristio i kod linklabele,i to radi dobro.
unit FEdit;
interface
uses
Windows,Graphics,Messages,SysUtils, Classes, Controls, StdCtrls,DBCtrls;
type
TFEdit = class(TDBEdit)
private
FBojaFontaEnter:TFont;
FBojaFontaExit:TFont;
FBackColor,FBackColorExit:TColor;
FOnExit,FOnEnter:TNotifyEvent;
function GetBackColor():TColor;
procedure SetBackColor(Boja:TColor);
function GetBackColorExit():TColor;
procedure SetBackColorExit(Boja:TColor);
function GetFontColorEnter():TFont;
procedure SetFontColorEnter(value:TFont);
function GetFontExit():TFont;
procedure SetFontExit(value:TFont);
procedure CMEnter(var Msg:TMessage);message CM_ENTER;
procedure CMExit(var Msg:Tmessage);message CM_EXIT;
protected
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
published
property Align;
property Anchors;
property AutoSize;
property BiDiMode;
property Color nodefault;
property Caption;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font nodefault;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Visible;
property OnClick;
property OnContextPopup;
property OnEnter:TNotifyEvent read FOnEnter write FOnEnter;
property OnExit:TNotifyEvent read FOnExit write FOnExit;
property DataSource;
property BojaPozEnter:TColor read FBackColor write FBackColor;
property BojaPozExit:TColor read FBackColorExit write FBackColorExit;
//property FontEnter:TFont read FBojaFontaEnter write FBojaFontaEnter;
property FontExit:TFont read FBojaFontaExit write FBojaFontaExit;
end;
procedure Register;
implementation
{$R *.dcr}
procedure Register;
begin
RegisterComponents('Moji', [TFEdit]);
end;
{ TFEdit }
procedure TFEdit.CMEnter(var Msg: TMessage);
begin
if (csDesigning in ComponentState) then Exit;
if Assigned(FOnEnter) then FOnEnter(Self);
Color:=FBackColor;
Font.Assign(FBojaFontaEnter);
Refresh;
end;
procedure TFEdit.CMExit(var Msg: Tmessage);
begin
if (csDesigning in ComponentState) then Exit;
if Assigned(FOnExit) then FOnExit(Self);
Color:=FBackColorExit;
Font.Assign(FBojaFontaExit);
Refresh;
end;
constructor TFEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBojaFontaEnter:=TFont.Create;
FBojaFontaEnter.Color:=clBlue;
FBojaFontaEnter.Style:=[];
FBojaFontaEnter.Assign(Font);
FBojaFontaExit:=TFont.Create;
FBojaFontaExit.Color:=clBlack;
FBojaFontaExit.Assign(Font);
end;
destructor TFEdit.Destroy;
begin
inherited;
end;
function TFEdit.GetBackColor: TColor;
begin
Result:=FBackColor;
end;
function TFEdit.GetBackColorExit: TColor;
begin
Result:=FBackColorExit;
end;
function TFEdit.GetFontColorEnter: TFont;
begin
Result:=FBojaFontaEnter;
end;
function TFEdit.GetFontExit: TFont;
begin
Result:=FBojaFontaExit;
end;
procedure TFEdit.SetBackColor(Boja: TColor);
begin
FBackColor:=Boja;
end;
procedure TFEdit.SetBackColorExit(Boja: TColor);
begin
FBackColorExit:=Boja;
end;
procedure TFEdit.SetFontColorEnter(value: TFont);
begin
FBojaFontaEnter.Assign(value);
end;
procedure TFEdit.SetFontExit(value: TFont);
begin
FBojaFontaExit.Assign(value);
end;
end.
U cemu je problem.Zahvalan
[mod by bobby] ubacio CODE tagove
|