Mengubah warna komponen aktif |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: 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 := clRed; (activeControl as TEdit).font.color := clYellow; 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. |
Tidak ada komentar:
Posting Komentar