AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Property (Stackoverload)

Ein Thema von Taladan · begonnen am 4. Sep 2003 · letzter Beitrag vom 5. Sep 2003
 
Benutzerbild von negaH
negaH

Registriert seit: 25. Jun 2003
Ort: Thüringen
2.950 Beiträge
 
#4

Re: Property (Stackoverload)

  Alt 4. Sep 2003, 14:53
So nun mal im Ernst, deine Klassen sind sehr unglücklich deklariert.
Delphi-Quellcode:
type
  TBitmaps = class(TPersistent)
  private
    FBitmaps: array[0..8] of TBitmap;

    function GetBitmap(Index: Integer): TBitmap;
    procedure SetBitmap(Index: Integer; Value: TBitmap);
  protected
  public
    destructor Destroy; override;
    procedure Assign(Source: TPersistent); override;
  published
    property TopLeft: TBitmap index 0 read GetBitmap write SetBitmap;
    property TopMiddle: TBitmap index 1 read GetBitmap write SetBitmap;
    property TopRight: TBitmap index 2 read GetBitmap write SetBitmap;

    property MiddleLeft: TBitmap index 3 read GetBitmap write SetBitmap;
    property MiddleMiddle: TBitmap index 4 read GetBitmap write SetBitmap;
    property MiddleRight: TBitmap index 5 read GetBitmap write SetBitmap;

    property BottomLeft: TBitmap index 6 read GetBitmap write SetBitmap;
    property BottomMiddle: TBitmap index 7 read GetBitmap write SetBitmap;
    property BottomRight: TBitmap index 8 read GetBitmap write SetBitmap;
  end;

implementation

function TBitmaps.GetBitmap(Index: Integer): TBitmap;
begin
  if FBitmaps[Index] = nil then FBitmaps[Index] := TBitmap.Create;
  Result := FBitmaps[Index];
end;

procedure TBitmaps.SetBitmap(Index: Integer; Value: TBitmap);
begin
  GetBitmap(Index).Assign(Value);
end;

procedure TBitmaps.Assign(Source: TPersistent);
var
  I: Integer;
  S: TBitmaps; absolute Source;
begin
  if Source is TBitmaps then
  begin
    for I := Low(FBitmaps) to High(FBitmaps) do
      SetBitmap(I, S.GetBitmap(I));
  end else inherited Assign(Source);
end;

destructor TBitmaps.Destroy;
var
  I: Integer;
begin
  for I := Low(FBitmaps) to High(FBitmaps) do
    FreeAndNil(FBitmaps[I]);
  inherited Destroy;
end;
Allerdings, ich vermute das alle 9 Bitmaps die gleiche Größe + Farbauflösung besitzen. Wenn ja, dann ist eine TImageList mit 9 Bitmaps die absolut bessere Wahl.

Gruß Hagen
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz