Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack Special Offer!


Share this page

Follow us
LinkedIn Blogspot Twitter Facebook

Related products
Ultimate Pack  hot!
iGrid Plotter  new!
Image Editor
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
Print Suite .NET
Gradient Controls .NET  new!

Related links
Win32.hlp online version
MegaDetailed.NET
Delphi to C#

Special
Free Software Promotion
Offers for Resellers

Hobby projects
cdtrrracks.com
books.storrre.com
in3steps.com
sovietphillumeny.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