[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

DBEdit component....

Posted on 1999-06-28
2
Medium Priority
?
408 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:StuartB_99
2 Comments
 
LVL 15

Accepted Solution

by:
simonet earned 200 total points
ID: 1384867
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384868
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question