Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 830
  • Last Modified:

Reseting TScrollBox

How can I reset a TScrollBox position?

I cant do this if I hide the VertScrollBar (Visible := FALSE); Or AutoScroll := FALSE.

ScrollBox1.VertScrollBar.Position := 0; <--- has no effect.

Please help me.

Thanks.



0
kapot
Asked:
kapot
  • 4
2 Solutions
 
mikelittlewoodCommented:
If you have VertScrollBar.Visible := FALSE, why would you need to reset it? Surely you cant move down the scrollbox in the first place?
0
 
mikelittlewoodCommented:
And if you had something in the scrollbox that was bigger than the vertical limit, then surely you need a vertical scrollbar no?
Then ScrollBox1.VertScrollBar.Position := 0 would work.
0
 
kapotAuthor Commented:
I made my own scrolling function, so I control it manually via code.

I put two TImage as buttons, UP and DOWN.

In the UP button, I call "ScrollBy(0, -5);"

In the Down button, I call "ScrollBy(0, 5);"

Why I do this, because I want to use my own graphic, the default look of scrollbox is ugly.

But, then I can not reset the scrollbox position to its default.

Maybe bug or something?

Try it your self, put 3 TButtons :
Button1 -> ScrollBox1.ScrollBy(0, -5);
Button2 -> ScrollBox1.ScrollBy(0,  5);
Button3 -> Try to reset it

But you need to hide the scrollbar (by setting .Visible := FALSE; or AutoScroll := FALSE);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mikelittlewoodCommented:
I found that if you set the component.top property of the component in the scrollbox ... seems to reset ok
0
 
mikelittlewoodCommented:
I put an Image component into the scrollbox, then scrolled it off screen all the way
Then called Image1.Top := 0. Put the top part of the image at the top of the scrollbox
0
 
SIG_BGCommented:
You shouldn't use th ScrollBy function with the control -> this only
scrolls the control canvas without udating its information properly.

Use WM_VSCROLL and WM_HSCROLL messages and send them to the control like that:

Control.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now