4

I have a Delphi TImage component wich show pictures. Sometimes the pictures are larger than the image size and requires scrolling. I dont want to use the stretch property and auto size property, I want to see the picture by scrolling it. how can I do this? I can use TScrollBox, but I don't know how to use it! best regards.

Rojin
  • 109
  • 3
  • 6
  • 5
    Just drop your image in a `TScrollBox` component at design time and set its position to the upper left corner. For smoothly animated scroll you can use code from [`this post`](http://stackoverflow.com/a/9503002/960757). – TLama May 26 '14 at 06:42
  • tanks a lot, but the TScrollBox doesn't need any other settings? – Rojin May 26 '14 at 06:46
  • No. That's all. Your image just needs to be the child of the scroll box. With default settings it shows and scales progress bars automatically by its children positions and if your image is larger than the scroll box client rectangle, it shows progress bar(s) by which you can move the content (your image). – TLama May 26 '14 at 06:56
  • I inserted image into scrollBox, using this code: ScrollBox.InsertControl(Image);but the scroll bars are not shown, I set the tracking property of vertScrollBar and HorzScrollBar true, but nothing happend! – Rojin May 26 '14 at 07:02
  • You have to set `AutoSize` to `True`. The scrollbox will then take care of the scrolling. – jpfollenius May 26 '14 at 07:57
  • 3
    @jpfollenius, if you mean enable `AutoSize` for the scroll box, then no. It would automatically resize the scroll box by its children and you'd never see scrollbars. For the image is `AutoSize` right option though. Rojin, it should work, even if you insert your image into the scroll box that way. – TLama May 26 '14 at 08:48
  • @TLama: Of course I am talking about the image. `AutoSize` for a scrollbox by definition makes no sense. – jpfollenius May 26 '14 at 11:30
  • 1
    @jpfollenius, I thought that, but had to react since the question talks about a scroll box all the time and you've commented *"You have to set AutoSize to True"* which is quite misleading in such context. – TLama May 26 '14 at 11:37
  • tnx a lot for all of your help, best regards. – Rojin Jun 01 '14 at 11:44
  • Another hint: it won't work, if the akRight/akBottom anchors are set (for the image) – Gabriel Dec 17 '21 at 22:01

1 Answers1

2

change Image.Align from alCustom to alNone

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
Miłosz
  • 21
  • 2