# VBForums CodeBank > CodeBank - Other >  [Delphi 7] - Add scrollbar to image

## Madboy

```
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;
```

----------

