whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

68 Visitors Online


 
...change the Background-Color of a Edit on a Focus Change?
Autor: Thomas Greiner
Homepage: http://www.economx.com
[ Print tip ]  

Tip Rating (22):  
     


type
  
TForm1 = class(TForm)
    {...}
    
procedure OnFieldEnter(Sender: TObject);
    procedure OnFieldExit(Sender: TObject);
  end;

  {...}

const
  
clFocused = TColor($00FFFF);   // color for focused field
  
clBlurred = TColor($FFFFFF);   // color for blurred field


implementation


procedure 
TForm1.OnFieldEnter(Sender: TObject);
begin
  if 
(Sender is TCustomEdit) then
    
TEdit(Sender).Color := clFocused;
   // you may change all properties as desired when element is entered
end;

procedure TForm1.OnFieldExit(Sender: TObject);
begin
  if 
(Sender is TCustomEdit) then
    
TEdit(Sender).Color := clBlurred;
end;

(*
  Now you select every element you want to change color
  if entered on your form and add the OnFieldEnter/OnFieldExit
  procedure to the OnEnter/OnExit event.
*)


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners