DBEdit component....

I need a DB component that has 2 xtra properties, OnEnterColor and OnExitColor, these are not a problem but I cannot override the OnEnter or OnExit event. OnEnter I simply need to change the DBEdit color to OnEnterColor and OnExit it needs to change to OnExitColor.
Its as simple as that. I can do it with the Click Event but not the OnEnter or OnExit...

Can anyone please help me..

Thanx in advance

Stuart
StuartB_99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simonetCommented:
unit DBEdit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Mask, DBCtrls;

type
  TDBEdit1 = class(TDBEdit)
  private
    FEnterColor : TColor;
    FExitColor : TColor;
    procedure CMEnter(var Message: TCMEnter); message CM_ENTER;
    procedure CMExit(var Message: TCMExit); message CM_EXIT;
    { Private declarations }
  protected
    { Protected declarations }
  public
     constructor Create(AOwner : TComponent); override;
    { Public declarations }
  published
    property EnterColor : TColor read FEnterColor write FEnterColor;
    property ExitColor: TColor read FExitColor write FExitColor;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('New', [TDBEdit1]);
end;

constructor TDBEdit1.Create(AOwner : TComponent);
begin
  inherited;
  FEnterColor := Font.Color;
  FExitColor := Font.Color;
end;

procedure TDBEdit1.CMEnter(var Message: TCMEnter);
begin
  Font.Color := FEnterColor;
end;

procedure TDBEdit1.CMExit(var Message: TCMExit);
begin
  Font.Color := FExitColor;
end;

end.

Yours,

Alex
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwilson032697Commented:
simonet: You're too fast! Here's my answer as a comment...

You will find that the OnEnter and OnExit events are called by DoEnter and DoExit events. These are protected virtual functions so you can do this:

class
  TMyDBEdit = class(...)
    protected
      procedure DoEnter; Override;
      procedure DoExit; Override;

...

end;


procedure TMyDBEdit.DoEnter;

begin
  Color := FEnterColor;
  Inherited;
end;


procedure TMyDBEdit.DoExit;

begin
  Color := FExitColor;
  Inherited;
end;

Cheers,

Raymond.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.