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

25 Visitors Online


 
...get / set system colors?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (3):  
     


var

  
OldColor: TColor;
  Element: TColor = COLOR_BTNFACE;

  {....}

{
  Set the color for a system element. SetSysColors function
  changes the current Windows session only.
  The new colors are not saved when Windows terminates.
  For a list of color elements see  Win32 API Help - Function GetSysColor

  Setzt die Farbe für ein System Element.
  SetSysColors wechselt die Farbe nur für die laufende Windows Sitzung.
  Die neuen Farben werden bei Neustart nicht gespeichert.
  Für eine Liste von Elementen siehe Win32 API Hilfe - Funktion GetSysColor


  Open the ColorDialog - and set the new color systemwide
  Öffnet den ColorDialog und setzt die neue Farbe systemweit
}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if 
ColorDialog1.Execute then
  begin
    
SetSysColors(1, Element, ColorDialog1.Color);
  end;
end;

{
  Save the old color value of the element COLOR_BTNFACE to restore on Button2 click
  Speichert den alten Farbwert vom Element COLOR_BTNFACE zum wiederherstellen
  wenn auf Button2 gedrückt wird.
}

procedure TForm1.FormShow(Sender: TObject);
begin
  
OldColor := GetSysColor(COLOR_BTNFACE);
end;

{
  Restore the old color value
  Stellt den alten Farbwert wieder her
}

procedure TForm1.Button2Click(Sender: TObject);
begin
  
SetSysColors(1, Element, OldColor);
end;


 

Rate this tip:

poor
very good


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