From bfb114a2eb1bb613fe126b43cfba733408358ca7 Mon Sep 17 00:00:00 2001 From: graemeg Date: Thu, 11 Oct 2007 10:25:31 +0000 Subject: * Reworked the GetEnumPropValueList() procedure used in the UI Designer. No more pointer arithmatic and no more compiler hints or warnings. --- examples/apps/uidesigner/vfdprops.pas | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/apps/uidesigner/vfdprops.pas b/examples/apps/uidesigner/vfdprops.pas index bc14e890..37daf557 100644 --- a/examples/apps/uidesigner/vfdprops.pas +++ b/examples/apps/uidesigner/vfdprops.pas @@ -126,7 +126,7 @@ type procedure EditStringList(sl: TStringList); -procedure GetEnumPropValueList(wg: TObject; const propname: string; sl: TStringList); +procedure GetEnumPropValueList(wg: TObject; const APropName: string; sl: TStringList); implementation @@ -152,25 +152,26 @@ begin frmie.Free; end; -procedure GetEnumPropValueList(wg: TObject; const propname: string; sl: TStringList); +procedure GetEnumPropValueList(wg: TObject; const APropName: string; sl: TStringList); var - pi: PPropInfo; - P: ^ShortString; - T: PTypeData; + lPropInfo: PPropInfo; + s: string; + lTypeData: PTypeData; n: integer; begin - pi := GetPropInfo(wg, propname); -{$ifdef FPC} - T := GetTypeData(pi^.PropType); -{$else} - T := GetTypeData(pi^.PropType^); -{$endif} - P := @T^.NameList; + lPropInfo := GetPropInfo(wg, APropName); + lTypeData := GetTypeData(lPropInfo^.PropType); - for n := 0 to T^.MaxValue do - begin - sl.Add(P^); - Inc(PtrInt(P), Length(P^) + 1); + sl.BeginUpdate; + try + sl.Clear; + for n := lTypeData^.MinValue to lTypeData^.MaxValue do + begin + s := GetEnumName(lPropInfo^.PropType, n); + sl.Add(s); + end; + finally + sl.EndUpdate; end; end; -- cgit v1.2.3-70-g09d2