我想另外写一控件更好了
从TDBEdit继承,处理wm_setfocus及wm_killfocus消息就可以了
unit MyDBEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, DBCtrls;
type
TMyDBEdit = class(TDBEdit)
private
FFocusColor: tcolor;
FNonFocusColor: Tcolor;
{ Private declarations }
procedure wmsetfocus(var msg:twmsetfocus);message wm_setfocus;
procedure wmkillfocus(var msg:twmkillfocus);message wm_killfocus;
procedure SetFocusColor(const Value: tcolor);
procedure SetNonFocusColor(const Value: Tcolor);
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property focuscolor:tcolor read FFocusColor write SetFocusColor;
property NonFocusColor:Tcolor read FNonFocusColor write SetNonFocusColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyDBEdit]);
end;
{ TMyDBEdit }
procedure TMyDBEdit.SetFocusColor(const Value: tcolor);
begin
FFocusColor := Value;
end;
procedure TMyDBEdit.SetNonFocusColor(const Value: Tcolor);
begin
FNonFocusColor := Value;
color:=FNonFocusColor;
end;
procedure TMyDBEdit.wmkillfocus(var msg: twmkillfocus);
begin
color:=FNonFocusColor;
end;
procedure TMyDBEdit.wmsetfocus(var msg: twmsetfocus);
begin
color:=FFocusColor;
end;
end.