size : 715
uploaded_on : Tue Sep 29 00:00:00 1998
modified_on : Wed Dec 8 14:03:10 1999
title : List an Enumerated Type
org_filename : listenum.txt
author : Andy Johnson
authoremail : ideadmin@sharry.demon.co.uk
description : Load a TStrings object with an Enumerated type.
keywords :
tested : Delphi 4
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-ide
__END_OF_HEADER__
uses TypInfo;
procedure EnumTypeAsStrings(anEnum: PTypeInfo; theStrings: TStrings);
var i: integer;
begin
if(anEnum.Kind = tkEnumeration)then
begin
theStrings.Clear;
for i:= GetTypeData(anEnum).MinValue to GetTypeData(anEnum).MaxValue do
begin
theStrings.AddObject( GetEnumName(anEnum,i), TObject(anEnum));
end;{}
end;{}
end;{}
=============================================================
An Example of use :
procedure TForm1.ListBox1Click(Sender: TObject);
var pti: PTypeInfo;
str : string;
begin
pti := PTypeInfo(ListBox1.Items.Objects[ListBox1.ItemIndex]);
str := ListBox1.Items[ListBox1.ItemIndex];
Panel1.BevelOuter := TBevelCut(GetEnumValue(pti,str));
end;