Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Scroll image with ScrollBars - Components - Tips & Tricks - Greatis Delphi Pages

If your picture has very large width or height, then you may use ScrollBars for scrolling of this picture.
For example, ScrollBar1 will change a horizontal position of this picture and ScrollBar2 will change a vertical position of this picture. Set OnChange event to Scrollbar2Change for each ScrollBar.


var
  MyBitmap: TBitmap;

...

procedure TForm1.ScrollBar2Change(Sender: TObject);
var
  RectDest, RectSource: TRect;
begin
  RectDest:=Rect(0, 0, Image1.Width, Image1.Height);
  RectSource:=Rect(
    ScrollBar1.Position, 
    ScrollBar2.Position, 
    Scrollbar1.Position+Image1.Width, 
    ScrollBar2.Position+Image1.Height);
  Image1.Canvas.CopyRect(RectDest, MyBitmap.Canvas, RectSource);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MyBitmap:=TBitmap.Create;
  MyBitmap.LoadFromFile('factory.bmp');
  Image1.Picture.Bitmap.Assign(MyBitmap);
  ScrollBar1.Max:=MyBitmap.Width-1-Image1.Width;
  ScrollBar2.Max:=MyBitmap.Height-1-Image1.Height;
end;
For more
Delphi Help

Download source