Thema: Delphi boolean ohne variable?

Einzelnen Beitrag anzeigen

Benutzerbild von Sharky
Sharky

Registriert seit: 29. Mai 2002
Ort: Frankfurt
8.251 Beiträge
 
Delphi 2006 Professional
 
#21

Re: boolean ohne variable?

  Alt 15. Dez 2004, 15:44
Es gibt schon Fälle wo es nett ist:
Delphi-Quellcode:
type
  TmyColor = record
      case boolean of
      true : (Color : TColor);
      false : (ColorR : Byte;
               ColorG : Byte;
               ColorB : Byte;)
  end;

procedure TForm1.Button1Click(Sender: TObject);
var
  myColor : TmyColor;
begin
  myColor.Color := clLime;
  Label1.Caption := 'Rotanteil : ' + IntToStr(mycolor.ColorR);
  Label2.Caption := 'Grünanteil : ' + IntToStr(mycolor.ColorG);
  Label3.Caption := 'Blauanteil : ' + IntToStr(mycolor.ColorB);
end;
Und schon kann ich ganz elegant auf die einzelnene Anteile einer Farbe zuweisen
Stephan B.
"Lasst den Gänsen ihre Füßchen"
  Mit Zitat antworten Zitat