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

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

•  TDictionary Custom Sort  6 724

•  Fast Watermark Sources  6 507

•  3D Designer  9 445

•  Sik Screen Capture  6 838

•  Patch Maker  7 288

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

•  ListBox Drag & Drop  6 090

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

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

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

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

•  Canvas Drawing  5 941

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

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

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

•  Paint on Shape  2 962

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

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

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

•  Пазл Numbrix  2 577

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

•  Игра HIP  2 312

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

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

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

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

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

•  HEX View  2 696

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

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Вывести информацию о возможных значениях свойств



Автор: Xavier Pacheco

unit MainFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids;

type
  TMainForm = class(TForm)
    lbSamps: TListBox;
    memInfo: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure lbSampsClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation
uses TypInfo, Buttons;

{$R *.DFM}

procedure TMainForm.FormCreate(Sender: TObject);
begin
  // Add some example enumerated types
  with lbSamps.Items do
  begin
    AddObject('TBorderIcons', TypeInfo(TBorderIcons));
    AddObject('TGridOptions', TypeInfo(TGridOptions));
  end;
end;

procedure GetTypeInfoForOrdinal(AOrdTypeInfo: PTypeInfo; AStrings: TStrings);
var
  //  OrdTypeInfo: PTypeInfo;
  OrdTypeData: PTypeData;

  TypeNameStr: string;
  TypeKindStr: string;
  MinVal, MaxVal: Integer;
  i: integer;
begin

  // Get the TTypeData pointer
  OrdTypeData := GetTypeData(AOrdTypeInfo);

  // Get the type name string
  TypeNameStr := AOrdTypeInfo.Name;
  // Get the type kind string
  TypeKindStr := GetEnumName(TypeInfo(TTypeKind), Integer(AOrdTypeInfo^.Kind));

  // Get the minimum and maximum values for the type
  MinVal := OrdTypeData^.MinValue;
  MaxVal := OrdTypeData^.MaxValue;

  // Add the information to the memo
  with AStrings do
  begin
    Add('Type Name: ' + TypeNameStr);
    Add('Type Kind: ' + TypeKindStr);

    // Call this function recursively to show the enumeration
    // values for this set type.
    if AOrdTypeInfo^.Kind = tkSet then
    begin
      Add('==========');
      Add('');
      GetTypeInfoForOrdinal(OrdTypeData^.CompType^, AStrings);
    end;

    // Show the values and names of the enumerated types belonging to the
    // set.
    if AOrdTypeInfo^.Kind = tkEnumeration then
    begin
      Add('Min Val: ' + IntToStr(MinVal));
      Add('Max Val: ' + IntToStr(MaxVal));

      for i := MinVal to MaxVal do
        Add(Format('  Value: %d   Name: %s', [i, GetEnumName(AOrdTypeInfo,
          i)]));
    end;
  end;

end;

procedure TMainForm.lbSampsClick(Sender: TObject);
begin
  memInfo.Lines.Clear;
  with lbSamps do
    GetTypeInfoForOrdinal(PTypeInfo(Items.Objects[ItemIndex]), memInfo.Lines);
end;
end.