unit _WindowList;

interface

uses
  System.Classes, System.Contnrs, Winapi.Windows;

type
  TWindowListItem = class(TObject)
  private
    FTitle: string;
    FHashedClassName: string;
    FClassName: string;
    FWidth: Integer;
    FState: Integer;
    FMaxX: Integer;
    FMaxY: Integer;
    FTop: Integer;
    FHeight: Integer;
    FLeft: Integer;
    FMinX: Integer;
    FMinY: Integer;
    FHandle: HWND;
    FHasChanged: Boolean;
    FAlwaysRestore: Boolean;
    FIsSizeable: Boolean;
    FIsWindowNewOpen: Boolean;
    FRestoreFlags: Cardinal;
    procedure SetTitle(const Value: string);
    procedure SetClassName(const Value: string);
    procedure SetHashedClassName(const Value: string);
    procedure SetHeight(const Value: Integer);
    procedure SetLeft(const Value: Integer);
    procedure SetMaxX(const Value: Integer);
    procedure SetMaxY(const Value: Integer);
    procedure SetMinX(const Value: Integer);
    procedure SetMinY(const Value: Integer);
    procedure SetState(const Value: Integer);
    procedure SetTop(const Value: Integer);
    procedure SetWidth(const Value: Integer);
    procedure SetHandle(const Value: HWND);
    procedure SetHasChanged(const Value: Boolean);
    procedure SetAlwaysRestore(const Value: Boolean);
    procedure SetIsSizeable(const Value: Boolean);
    procedure SetIsWindowNewOpen(const Value: Boolean);
    procedure SetRestoreFlags(const Value: Cardinal);
  public
    property Handle: HWND read FHandle write SetHandle;
    property Title: string read FTitle write SetTitle;
    property ClassName: string read FClassName write SetClassName;
    property HashedClassName: string read FHashedClassName write SetHashedClassName;
    property AlwaysRestore: Boolean read FAlwaysRestore write SetAlwaysRestore;
    property Top: Integer read FTop write SetTop;
    property Left: Integer read FLeft write SetLeft;
    property Width: Integer read FWidth write SetWidth;
    property Height: Integer read FHeight write SetHeight;
    property State: Integer read FState write SetState;
    property MinX: Integer read FMinX write SetMinX;
    property MinY: Integer read FMinY write SetMinY;
    property MaxX: Integer read FMaxX write SetMaxX;
    property MaxY: Integer read FMaxY write SetMaxY;
    property IsSizeable: Boolean read FIsSizeable write SetIsSizeable;
    property RestoreFlags: Cardinal read FRestoreFlags write SetRestoreFlags;
    property HasChanged: Boolean read FHasChanged write SetHasChanged;
    property IsWindowNewOpen: Boolean read FIsWindowNewOpen write SetIsWindowNewOpen;
  end;

  TWindowList = class(TObjectList)
  private
  protected
    function GetItem(Index: Integer): TWindowListItem;
    procedure SetItem(Index: Integer; AObject: TWindowListItem);
  public
    function Add(AObject: TWindowListItem): Integer;
    function GetItemByHashedClassName(const AHashedClassName: string): TWindowListItem;
    property Items[Index: Integer]: TWindowListItem read GetItem write SetItem;
  end;

implementation

{ TWindowListItem }

procedure TWindowListItem.SetAlwaysRestore(const Value: Boolean);
begin
  FAlwaysRestore := Value;
end;

procedure TWindowListItem.SetClassName(const Value: string);
begin
  FClassName := Value;
end;

procedure TWindowListItem.SetHandle(const Value: HWND);
begin
  FHandle := Value;
end;

procedure TWindowListItem.SetHasChanged(const Value: Boolean);
begin
  FHasChanged := Value;
end;

procedure TWindowListItem.SetHashedClassName(const Value: string);
begin
  FHashedClassName := Value;
end;

procedure TWindowListItem.SetHeight(const Value: Integer);
begin
  FHeight := Value;
end;

procedure TWindowListItem.SetIsSizeable(const Value: Boolean);
begin
  FIsSizeable := Value;
end;

procedure TWindowListItem.SetIsWindowNewOpen(const Value: Boolean);
begin
  FIsWindowNewOpen := Value;
end;

procedure TWindowListItem.SetLeft(const Value: Integer);
begin
  FLeft := Value;
end;

procedure TWindowListItem.SetMaxX(const Value: Integer);
begin
  FMaxX := Value;
end;

procedure TWindowListItem.SetMaxY(const Value: Integer);
begin
  FMaxY := Value;
end;

procedure TWindowListItem.SetMinX(const Value: Integer);
begin
  FMinX := Value;
end;

procedure TWindowListItem.SetMinY(const Value: Integer);
begin
  FMinY := Value;
end;

procedure TWindowListItem.SetRestoreFlags(const Value: Cardinal);
begin
  FRestoreFlags := Value;
end;

procedure TWindowListItem.SetState(const Value: Integer);
begin
  FState := Value;
end;

procedure TWindowListItem.SetTitle(const Value: string);
begin
  FTitle := Value;
end;

procedure TWindowListItem.SetTop(const Value: Integer);
begin
  FTop := Value;
end;

procedure TWindowListItem.SetWidth(const Value: Integer);
begin
  FWidth := Value;
end;

{ TWindowList }

function TWindowList.Add(AObject: TWindowListItem): Integer;
begin
  Result := inherited Add(AObject);
end;

function TWindowList.GetItem(Index: Integer): TWindowListItem;
begin
  Result := TWindowListItem(inherited Items[Index]);
end;

function TWindowList.GetItemByHashedClassName(
  const AHashedClassName: string): TWindowListItem;
var
  i: Integer;
begin
  Result := nil;

  for i := 0 to Count - 1 do
  begin
    if AHashedClassName = Items[i].HashedClassName then
    begin
      Result := Items[i];
    end;
  end;
end;

procedure TWindowList.SetItem(Index: Integer; AObject: TWindowListItem);
begin
  inherited Items[Index] := AObject;
end;

end.
