Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Scrollbarbalken sollen gezoomte Größe widerspiegeln (https://www.delphipraxis.net/107040-scrollbarbalken-sollen-gezoomte-groesse-widerspiegeln.html)

daschaos 21. Jan 2008 10:48


Scrollbarbalken sollen gezoomte Größe widerspiegeln
 
Hi!

Ich habe ein CustomPanel. Damit ich Flickern vermeide, zeichne ich meine Ausgabe zuerst auf ein Bitmap, dass ich dann aufs Canvas des Panels zeichne. Dieses Bitmap kann man durch Benutzereingabe vergrößern. Demenstprechend hab ich mir eine vertikale und horizontale ScrollBar erzeugt, die mir hilft, das Bild in seiner Gesamtheit zu scrollen. Das funktioniert auch soweit, allerdings hätte ich gerne dass sich die Scrollbalken je nach Größe der gesamten ScrollBar Range und PageSize anpassen. Wie stelle ich das an? Habe hier im Forum schon gesucht, wurde bisher aber leider nicht fündig.

Hier mal mein Code bisher:

Delphi-Quellcode:
procedure ScrollBarVerScroll(Sender: TObject; ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  SY := ScrollPos;
  ScrollPos := 5 * ((ScrollPos + 2) div 5);

  ScrollBarVer.Min := 0;
  ScrollBarVer.Max := FDoubleBufferedBitmap.Height - Height + ScrollBarHor.Height;
  ScrollBarVer.PageSize := Height - ScrollBarHor.Height;

  CalcPanelView;
end;

procedure ScrollBarHorScroll(Sender: TObject; ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  SX := ScrollPos;
  ScrollPos := 5 * ((ScrollPos + 2) div 5);

  ScrollBarHor.Min := 0;
  ScrollBarHor.Max := FDoubleBufferedBitmap.Width - Width + ScrollBarVer.Width;
  ScrollBarHor.PageSize := Width - ScrollBarVer.Width;

  CalcPanelView;
end;

procedure CalcPanelView;
begin
  if ((SX+Width) >= Width) and ((SY+Height) >= Height) then
    BitBlt(Canvas.Handle, 0, 0, Width-ScrollBarVer.Width, Height-ScrollBarHor.Height, FDoubleBufferedBitmap.Canvas.Handle,
      SX, SY, SRCCOPY)
  else
    BitBlt(Canvas.Handle, 0, 0, Width-ScrollBarVer.Width, Height-ScrollBarHor.Height, FDoubleBufferedBitmap.Canvas.Handle,
      FDoubleBufferedBitmap.Width - Width, FDoubleBufferedBitmap.Height - Height, SRCCOPY);
end;

procedure Zoom;
var
  Scale: Double;
begin
  IsZoom := True;

  ScrollBarVer.Visible := True;
  ScrollBarHor.Visible := True;

  Scale := ZoomFactor / 100;

  ZoomRect.Left := 0;
  ZoomRect.Top := 0;
  ZoomRect.Right := Round(ClientRect1.Right * Scale);
  ZoomRect.Bottom := Round(ClientRect1.Bottom * Scale);

  if (ZoomRect.Bottom <= ClientRect1.Bottom) or (ZoomRect.Right <= ClientRect1.Right) then
  begin
    ScrollBarVer.Visible := False;
    ScrollBarHor.Visible := False;
    IsZoom := False;
    ZoomRect := Rect(0, 0, Width, Height);
    Self.Invalidate;
  end;

  if (ZoomRect.Bottom > 3*Height) or (ZoomRect.Right > 3*Width) then
  begin
    IsZoom := False;
    exit;
  end;

  FDoublebufferedBitmap.Height := ZoomRect.Bottom;
  FDoublebufferedBitmap.Width := ZoomRect.Right;

  Draw(FDoublebufferedBitmap.Canvas, ZoomRect);

  BitBlt(FDoublebufferedBitmap.Handle, 0, 0, ClientRect1.Right-ScrollBarVer.Width, ClientRect1.Bottom-ScrollBarHor.Height,
    FDoubleBufferedBitmap.Canvas.Handle, SX, SY, SRCCOPY);

  Canvas.Draw(0,0, FDoublebufferedBitmap);
end;
Wäre für jede Hilfe dankbar!

Liebe Grüße,
Laura


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:09 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz