Board index » cppbuilder » Using TScrollBar and TPanel to act similar to TScrollBox

Using TScrollBar and TPanel to act similar to TScrollBox

I need to get a TPanel and a TScroll bar to act similar to a TScrollBox.  I
only need scrolling in one direction (horizontal).  The reason I can't use
TScrollBox is because I need the TScrollBar to be "outside" the TPanel such
that TScrollBar->Parent != TPanel.  This is so because TPanel is inside a
TScrollBox with another group of controls that scroll Vertically.

I figured out how to get the panel to scroll using the ScrollBy method.  I
also got the code from the help file to set the PageSize property.

What I can't figure out is how to get the scrolling coordinated with the
resizing of the entire form.  If you notice with TScrollbox, if the
scrollbox is partially scrolled and the page is resized then the scrollbox
automatically scrolls until the entire contents of the box is in view.

I have looked in CodeCentral and could not find any useful examples.

Thanks
Chris

 

Re:Using TScrollBar and TPanel to act similar to TScrollBox


Quote
Chris Martin wrote:

> What I can't figure out is how to get the scrolling coordinated with the
> resizing of the entire form.  

        ????

Quote
> If you notice with TScrollbox, if the
> scrollbox is partially scrolled and the page is resized then the scrollbox
> automatically scrolls until the entire contents of the box is in view.

If you have a ScrollBox on a Form and the Form is resized then the
ScrollBox does nothing except for if the ScrollBox Align property is
for instance set to alClient.

Now if you want your scrollable Panel to coordinate while resizing the
Form
do you want it to resize ?

While resizing to have to adapt the Pagesize and the Max of your
ScrollBar.
Then compare the value of Position + Pagesize to that of Max.
If the sum is greater than Max lower Position untill you have what you
want.

You could use a second ScrollBox instead of your TPanel + ScrollBar I
think.

Hans.

Re:Using TScrollBar and TPanel to act similar to TScrollBox


Thank you for for reply.

Quote
> If you have a ScrollBox on a Form and the Form is resized then the
> ScrollBox does nothing except for if the ScrollBox Align property is
> for instance set to alClient.

Sorry.  I forgot to mention that all panels are panels are Align=alClient.

Quote
> Now if you want your scrollable Panel to coordinate while resizing the
> Form
> do you want it to resize ?

Yes

Quote
> While resizing to have to adapt the Pagesize and the Max of your
> ScrollBar.
> Then compare the value of Position + Pagesize to that of Max.
> If the sum is greater than Max lower Position untill you have what you
> want.

Thanks I'll check it out.

Quote
> You could use a second ScrollBox instead of your TPanel + ScrollBar I
> think.

I've tried everything I can think of.  This form is kind of a "scrolling
grid with fixed labels"  The form has a dynamic number of rows that need
vertical scrolling for the entire row.  Each row consists of a fixed label
and a dynamic list of TEdit boxes.  Since the list of TEdit Boxes is dynamic
then they need to scroll horizontally without scrolling the label.  I tried
a TScrollBox within a TScroll box and it worked except when there were a lot
of rows and a lot of columns then the horizontal scroll bar was beyond the
visible part of the vertical scroll box.  So if you were on the first column
on the first row and you wanted to get to the last column on the first row
then you had to scroll down to the last row to get to the horizontal scroll
bar then scroll to the last column then scroll back up to the first row.

Thanks again for your help.
Chris

Quote
"Hans Galema" <j.m.gal...@maartens.nl> wrote in message

news:3C643A72.271E674A@maartens.nl...
Quote
> Chris Martin wrote:

> > What I can't figure out is how to get the scrolling coordinated with the
> > resizing of the entire form.

> ????

> > If you notice with TScrollbox, if the
> > scrollbox is partially scrolled and the page is resized then the
scrollbox
> > automatically scrolls until the entire contents of the box is in view.

> If you have a ScrollBox on a Form and the Form is resized then the
> ScrollBox does nothing except for if the ScrollBox Align property is
> for instance set to alClient.

> Now if you want your scrollable Panel to coordinate while resizing the
> Form
> do you want it to resize ?

> While resizing to have to adapt the Pagesize and the Max of your
> ScrollBar.
> Then compare the value of Position + Pagesize to that of Max.
> If the sum is greater than Max lower Position untill you have what you
> want.

> You could use a second ScrollBox instead of your TPanel + ScrollBar I
> think.

> Hans.

Other Threads