Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DBEdit component....

Posted on 1999-06-28
2
Medium Priority
?
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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