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

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

•  TDictionary Custom Sort  6 599

•  Fast Watermark Sources  6 369

•  3D Designer  9 319

•  Sik Screen Capture  6 703

•  Patch Maker  7 084

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

•  ListBox Drag & Drop  5 955

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

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

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

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

•  Canvas Drawing  5 826

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

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

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

•  Paint on Shape  2 864

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

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

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

•  Пазл Numbrix  2 519

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

•  Игра HIP  2 186

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

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

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

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

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

•  HEX View  2 635

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

 
скрыть

Список кнопок



unit BtnsList;

interface

uses
  Classes, StdCtrls;

type
  TButtonList = class(TObject)
  private
    FList: TList;
    function Get(Index: Integer): TButton;
    procedure Put(Index: Integer; Item: TButton);
    function GetCount: Integer;
  public
    constructor Create;
    destructor Destroy; override;
    function Add(Item: TButton): Integer;
    function Equals(List: TButtonList): Boolean;
    property Count: Integer
      read GetCount;
    property Items[Index: Integer]: TButton
    read Get write Put; default;
  end;

implementation

constructor TButtonList.Create;
begin
  inherited Create;
  FList := TList.Create;
end;

destructor TButtonList.Destroy;
begin
  FList.Free;
  inherited Destroy;
end;

function TButtonList.Get(Index: Integer): TButton;
begin
  Result := FList[Index];
end;

procedure TButtonList.Put(Index: Integer; Item: TButton);
begin
  FList[Index] := Item;
end;

function TButtonList.GetCount: Integer;
begin
  Result := FList.Count;
end;

function TButtonList.Add(Item: TButton): Integer;
begin
  Result := FList.Add(Item);
end;

function TButtonList.Equals(List: TButtonList): Boolean;
var
  I: Integer;
begin
  Result := False;
  if List.Count <> FList.Count then
    Exit;
  for I := 0 to List.Count - 1 do
    if List[I] <> FList[I] then
      Exit;
  Result := True;
end;

end.
unit ListForm;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    SpeedButton1: TSpeedButton;
    ListBox1: TListBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure AddToList(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure UpdateList(Sender: TObject);
  private
    List: TButtonList;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.AddToList(Sender: TObject);
begin
  // checks the type
  List.Add(Sender as TButton);
  // no go:
  // List.Add (Sender);
  UpdateList(self);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  List := TButtonList.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  List.Free;
end;

procedure TForm1.UpdateList(Sender: TObject);
var
  I: Integer;
begin
  ListBox1.Items.Clear;
  for I := 0 to List.Count - 1 do
    ListBox1.Items.Add(Format('%s (%s)',
      [List[I].Caption, List[I].ClassName]));
end;

end.
Скачать весь проект