| 
| 
 | Вопрос # 2 531/ вопрос открыт / | 
 |  Здравствуйте, эксперты!Вопрос о корректности работы с множествами. В случае если работаешь с прямым указанием на тип данных (например, TAlign), то все элементы выводятся корректно вызовом функцией GetEnumName(TypeInfo(TAlign), i). Но, если будешь работать из класса, то появляются какие-то дополнительные элементы. Как же определить все элементы (имена) множества из класса???
 Приложение:Переключить в обычный режим unit main; {$M+} interface uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, TypInfo, StdCtrls; type  TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;  private    { Private declarations }  public    { Public declarations }  end; var  Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);var  APropData: PTypeData;  APropList: PPropList;  i,n: integer;begin  APropData := GetTypeData(TMemo.ClassInfo);   if APropData.PropCount > 0 then  begin    GetMem(APropList, SizeOf(APropList) * APropData.PropCount);     try      GetPropInfos(TMemo.ClassInfo, APropList);       for i := 0 to APropData.PropCount - 1 do      begin        case APropList[i].PropType^.Kind of          tkEnumeration:            if APropList[i].Name = 'Align' then            begin              ShowMessage(IntToStr(Ord(High(APropList[i]^.PropType^.Kind))));              for n := Ord(Low(APropList[i].PropType^.Kind)) to
Ord(High(APropList[i].PropType^.Kind)) do                ShowMessage(GetEnumName(APropList[i].PropType^, n));            end;        end;      end;    finally      FreeMem(APropList, SizeOf(APropList) * APropData.PropCount);    end;  end;end; end.
|  |   Вопрос задал: richman78 (статус: Посетитель)Вопрос отправлен: 16 марта 2009, 11:27
 Состояние вопроса: открыт, ответов: 0.
 |  
 Мини-форум вопросаВсего сообщений: 2; последнее сообщение — 16 марта 2009, 16:44; участников в обсуждении: 1. 
|   | richman78 (статус: Посетитель), 16 марта 2009, 16:41 [#1]:Спасибо! Разобрался!!! |  
|   | richman78 (статус: Посетитель), 16 марта 2009, 16:44 [#2]:Процедура должна быть такого плана: 
 procedure TForm1.Button1Click(Sender: TObject);
 var
 APropData: PTypeData;
 APropList: PPropList;
 ATypeInfo: PTypeInfo;
 AEnumData: PTypeData;
 i,n: integer;
 begin
 APropData := GetTypeData(Memo1.ClassInfo);
 
 if APropData.PropCount > 0 then
 begin
 GetMem(APropList, SizeOf(APropList) * APropData.PropCount);
 
 try
 GetPropInfos(Memo1.ClassInfo, APropList);
 
 for i := 0 to APropData.PropCount - 1 do
 begin
 case APropList[i].PropType^.Kind of
 tkEnumeration:
 if APropList[i].Name = 'Align' then
 begin
 ATypeInfo := APropList[i].PropType^;
 AEnumData := GetTypeData(ATypeInfo);
 
 ShowMessage(IntToStr(AEnumData^.MinValue) + 'x' + IntToStr(AEnumData^.MaxValue));
 for n := AEnumData.MinValue to AEnumData.MaxValue do ShowMessage(GetEnumName(ATypeInfo, n));
 end;
 end;
 end;
 finally
 FreeMem(APropList, SizeOf(APropList) * APropData.PropCount);
 end;
 end;
 end;
 |  Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте. |