Einzelnen Beitrag anzeigen

Satty67

Registriert seit: 24. Feb 2007
Ort: Baden
1.566 Beiträge
 
Delphi 2007 Professional
 
#18

Re: Anzahl Elemente in "set of"

  Alt 9. Apr 2009, 21:09
Zumindes <> 0 geht so...
Delphi-Quellcode:
type
  TFontStyle = (fsBold, fsItalic, fsStrikeOut, fsUnderline);
  TFontStyles = set of TFontStyle;

procedure Test(const Styles: TFontStyles);
var
  anzahlAttribute: Integer;
begin
  anzahlAttribute := Byte(Styles); // <--- Tata

  case anzahlAttribute of
    0: ShowMessage('STYLES ist leer');
    1: ShowMessage('STYLES hat ein Attribut');
  else
    ShowMessage(Format('STYLES hat %d Attribute', [anzahlAttribute]));
  end;
end;
Zumindest in D5 sind die Bits je nach Listen-Element gesetzt.
  Mit Zitat antworten Zitat