Software Software
asked on
Determine the dynamic length of the scrollbar
Hello,
in my form is a scrollbox.
Within the scrollbox I have a TImage.
1) The scrollbox should have only a scrollbar if the generated content does not fit on the image. Contents are drawings of rectangles.
2) The scrollbox should only be as high as the generated content, but should be at least X pixels high.
3) When I draw a rectangle out of the view, then the rectangle should be visible, when scrolling.
How can I implement this?
These questions are so important.
Thank you
in my form is a scrollbox.
Within the scrollbox I have a TImage.
1) The scrollbox should have only a scrollbar if the generated content does not fit on the image. Contents are drawings of rectangles.
2) The scrollbox should only be as high as the generated content, but should be at least X pixels high.
3) When I draw a rectangle out of the view, then the rectangle should be visible, when scrolling.
How can I implement this?
These questions are so important.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
Image1: TImage;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
left:=5;
top:=10;
form1.Width:=Screen.Width-15;
form1.Height:=Screen.Height-50;
ScrollBox1.Align:=alClient;
image1.Left:=0;
image1.Top:=0;
image1.Width:=ScrollBox1.Width;
image1.Height:=ScrollBox1.Height;
image1.Canvas.Rectangle(1400,50,2000,100);
end;
end.
Thank you
You have lots of stuff under FormActivate event. Most should be (or better be) defined in design mode (via property toolbox)
Draw your graphic (TBitmap) in back - assign to TImage, set TImage as AutoSize and Scrollbox to autosize too as Geert said.
Draw your graphic (TBitmap) in back - assign to TImage, set TImage as AutoSize and Scrollbox to autosize too as Geert said.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
everything drawn outside the TGraphic contained in the TImage is clipped
you should study the differences between a container object and a non container object
what objects have a canvas and how to draw on them
a TPersistent object
the autosize property of Tscrollbox ...