Change scroller size

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

Dear all,
imagine this is scroll bar.
Min|-------------|scroller|---------|Max
The position of scroller is set with Value.
How do I change the width of scroller?
Thank you in advance,
Boni
 
the width of the thumb (what you call the scroller) is dynamically set based
on the min and max size. It's not something you want to just change because
its determined automatically what size it should be in windows. You can
change it using API calls but it is a little pointless.
 
Hi Brian
on the min and max size. It's not something you want to just change
because its determined automatically what size it should be in windows.
But how is it determinated? In dependency of what?
Thanks,
Boni
 
Boni said:
But how is it determinated? In dependency of what?

The width of the thumb for horizontal scrollbars depends on the value of the
scrollbar's 'LargeChange' property too. The code below demonstrates how to
approximately calculate the width of the thumb for an horizontal scrollbar.
To test the sample, place a button control and an horizontal scrollbar on
the form and add the code below to the button's 'Click' event. After
pressing the button it will be moved below the scrollbar and its width will
be approximately equal to the scrollbar's thumb's width (note that the code
was written from scratch!):

\\\
Me.Button1.Left = _
Me.HScrollBar1.Left + SystemInformation.HorizontalScrollBarHeight
Me.Button1.Top = _
Me.HScrollBar1.Top + Me.HScrollBar1.Height
Me.Button1.Width = _
CInt( _
Me.HScrollBar1.LargeChange * _
( _
Me.HScrollBar1.Width - 2 * _
SystemInformation.HorizontalScrollBarHeight _
) / 100 _
)
///
 
Hi Herfried,
thank you very much.
Just one more question
The width of the thumb for horizontal scrollbars depends on the value of
the scrollbar's 'LargeChange' property too.
This "too" what does it mean. If I understand you correctly it depoends on
Minimum, Maximum and LargeChange property ONLY? Or is there some other
things?
And thanks for your code.
Boni
 
Boni said:
This "too" what does it mean.

It only means that 'LargeChange' is an additional dependency.
If I understand you correctly it depoends on Minimum, Maximum and
LargeChange property ONLY? Or is there some other things?

It depends on the width of the scrollbar (for horizontal scrollbars) too
;-).
 
Now I am really confused:
You give following formula:
TumbWidth= CInt( Me.HScrollBar1.LargeChange * (
Me.HScrollBar1.Width - 2 *
stemInformation.HorizontalScrollBarHeight ) / 100
I need to have formula to LargeChange for given ThumbWidth
LargeChange =TumbWidth*100/( Me.HScrollBar1.Width - 2 *
SystemInformation.HorizontalScrollBarHeight )

Now I want to have Tumb as a 10-th of width and looking for large change:
LargeChange =( (Me.HScrollBar1.Width - 2 *
SystemInformation.HorizontalScrollBarHeight )/10)*100/(
Me.HScrollBar1.Width - 2 *
stemInformation.HorizontalScrollBarHeight )=10. So it does not depend on
Minimum and maximum.
Unfortunately tests shows that my formula is wrong :(.
Did I missed something or is your formula incorrect too?
 
Boni said:
Now I want to have Tumb as a 10-th of width and looking for large change:
LargeChange =( (Me.HScrollBar1.Width - 2 *
SystemInformation.HorizontalScrollBarHeight )/10)*100/(
Me.HScrollBar1.Width - 2 *
Information.HorizontalScrollBarHeight )=10. So it does not depend on
Minimum and maximum.
Unfortunately tests shows that my formula is wrong :(.
Did I missed something or is your formula incorrect too?

The width of the thumb depends on the difference between the maximum and the
minimum in relation to the large change interval.

\\\
Me.HScrollBar1.LargeChange = _
(Me.HScrollBar1.Maximum - Me.HScrollBar1.Minimum) \ 10
///
 
Thank you very much for your time.
Herfried K. Wagner said:
The width of the thumb depends on the difference between the maximum and
the minimum in relation to the large change interval.

\\\
Me.HScrollBar1.LargeChange = _
(Me.HScrollBar1.Maximum - Me.HScrollBar1.Minimum) \ 10
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top