Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 796

•  TDictionary Custom Sort  6 793

•  Fast Watermark Sources  6 581

•  3D Designer  9 534

•  Sik Screen Capture  6 918

•  Patch Maker  7 365

•  Айболит (remote control)  7 303

•  ListBox Drag & Drop  6 168

•  Доска для игры Реверси  98 108

•  Графические эффекты  7 481

•  Рисование по маске  6 774

•  Перетаскивание изображений  5 630

•  Canvas Drawing  6 007

•  Рисование Луны  5 798

•  Поворот изображения  5 251

•  Рисование стержней  3 843

•  Paint on Shape  2 999

•  Генератор кроссвордов  3 955

•  Головоломка Paletto  3 138

•  Теорема Монжа об окружностях  3 969

•  Пазл Numbrix  2 620

•  Заборы и коммивояжеры  3 431

•  Игра HIP  2 347

•  Игра Go (Го)  2 264

•  Симулятор лифта  2 664

•  Программа укладки плитки  2 225

•  Генератор лабиринта  2 775

•  Проверка числового ввода  2 385

•  HEX View  2 720

•  Физический маятник  2 411

 
скрыть

Как сделать текстовый список всех доступных свойств перечисляемого типа



Автор: Sen

I need to get a list of strings (like a StringList) with the possible values for a TBrushStyle property (bsSolid, bsClear, bsHorizontal, for example). I want to build a ComboBox with this options. How can I set the property Items of my ComboBox directly with all the values from the enumerated type TBrushStyle? My ComboBox will be alike the Property Editor for this type.

You can use runtime type information (RTTI) to do that. Below is an example:

uses
  {...}, TypInfo

procedure BrushStylesAsStrings(AList: TStrings);
var
  a: integer;
  pInfo: PTypeInfo;
  pEnum: PTypeData;
begin
  AList.Clear;
  pInfo := PTypeInfo(TypeInfo(TBrushStyle));
  pEnum := GetTypeData(pInfo);
  with pEnum^ do
  begin
    for a := MinValue to MaxValue do
      AList.Add(GetEnumName(pInfo, a));
  end;
end;