Tips Membuat Warna Aktif pada TEdit


pelanggan

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, GradPnl, dxCore, dxButtons, ExtCtrls, Variants;

type
TForm1 = class(TForm)
pnl2: TPanel;
btnSimpan: TdxButton;
btnBatal: TdxButton;
pnl1: TPanel;
GradientPanel1: TGradientPanel;
pnl3: TPanel;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
lbl7: TLabel;
lbl9: TLabel;
lbl10: TLabel;
lbl11: TLabel;
lbl5: TLabel;
lbl8: TLabel;
lbl6: TLabel;
lbl4: TLabel;
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
edt4: TEdit;
edt5: TEdit;
edt6: TEdit;
edt7: TEdit;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
procedure
DoActiveControl(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
OldControl: TComponent;

implementation

{$R *.dfm}

procedure TForm1.DoActiveControl(Sender: TObject);
begin
if assigned(OldControl) then
begin
(OldControl as TEdit).color := clWhite;
(OldControl as TEdit).font.color := clBlack;
end;
if activeControl is TEdit then
begin
(activeControl as TEdit).color :=  $008DFCC1;
(activeControl as TEdit).font.color := clBlack;
OldControl := activeControl as TEdit;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
screen.OnActiveControlChange := DoActiveControl;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// mencegah terjadinya GP Fault
screen.OnActiveControlChange := nil
end;

end.


Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s