Einzelnen Beitrag anzeigen

CHackbart

Registriert seit: 22. Okt 2012
260 Beiträge
 
#4

AW: [FMX] Image mit Scrollfunktion

  Alt 17. Mär 2016, 18:57
Ich poste mal eine etwas aufgeräumte Variante von meinem Ansatz:

Delphi-Quellcode:
type
  TVirtualScrollBox = class(TCustomScrollBox)
  private
    FContentSize: TPointF;
  protected
    procedure DoPaint; override;
    function DoCalcContentBounds: TRectF; override;
    function GetDefaultStyleLookupName: string; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

constructor TVirtualScrollBox.Create(AOwner: TComponent);
begin
  inherited;
  FContentSize := PointF(10000, 10000);
end;

procedure TVirtualScrollBox.DoPaint;
begin
  inherited;
  canvas.Fill.Color := $FF000000;
  canvas.FillText(ClipRect, format('%0.2f/%0.2f',
    [HScrollBarValue / FContentSize.X, VScrollBarValue / FContentSize.Y]),
    false, 1, [], TTextAlign.Center, TTextAlign.Center);
end;

function TVirtualScrollBox.DoCalcContentBounds: TRectF;
begin
  result := RectF(0, 0, FContentSize.X, FContentSize.Y);
end;

function TVirtualScrollBox.GetDefaultStyleLookupName: string;
begin
  result := 'framedscrollboxstyle';
end;
Im Prinzip muss man nur DoPaint überschreiben mit seiner eigenen Logik. Mir gefällt das Basiskonstrukt in der Form nicht wirklich, aber es läuft recht passabel. Eventuell kann das ja jemand auch nutzen

Christian
  Mit Zitat antworten Zitat