0

I have using the GetScrollInfo native method to get the scroll values of the control and have set the values to my custom scrollbars. I Can able to find the minimum, maximum, value and the large change of the system scrollbar by using the SCROLLINFO. but i could not able to get the SmallChange value.

Code Snippet:

GetScrollInfo(control.Handle, SB_HORZ, ref hScrollInfo)

private void UpdateScrollBarValues(ScrollBarBase bar, ref SCROLLINFO scrollInfo)
    {
        bar.Minimum = scrollInfo.nMin;
        bar.Maximum = scrollInfo.nMax;
        bar.Value = scrollInfo.nPos;
        bar.LargeChange = scrollInfo.nPage;
        //How can we calculate or set the 
        //bar.SmallChange = ??
    }

Is there any other alternate method to find the small change of the system scrollbar is available??

Adhi
  • 147
  • 1
  • 11

1 Answers1

1

Pressing one of the arrow keys or clicking one of the scroll bar buttons makes the Value property changes according to the value set in the SmallChange property.

SmallChange(and also LargeChange) properties are set relative to the size of the view that the user sees, not to the total size including the unseen part. Refer MSDN

Therefor you can set a value as per suitable to you, like

bar.SmallChange = scrollInfo.nPage/20; 

Another so post to do perfect calculation.

Community
  • 1
  • 1
Anil
  • 3,722
  • 2
  • 24
  • 49
  • Hi @Anil, Thanks for your suggestion. What is the common factor for calculating the SmallChange. Is that 20 is the default?? or is there any generic factor is available. – Adhi Apr 11 '17 at 05:08
  • The default value is 1 – Anil Apr 11 '17 at 08:30
  • I have used the code like below `bar.SmallChange = Math.Max(1, (scrollInfo.nMax -scrollInfo.nPage) / 20);` Is that the **nPage/20** is correct in this case?? – Adhi Apr 11 '17 at 09:17
  • Shall i use this term for finding the SmallChange? – Adhi Apr 11 '17 at 10:02
  • SmallChange and LargeChange properties are set relative to the size of the view that the user sees, not to the total size, so your solution is ok to me, in this case you can also set `LargeChange=scrollInfo.nMax -scrollInfo.nPage`. Divide by 20 (or any number suitable to you) means, 20 times click on any (scroll buttons/up/down keys) should scroll the box equal to LargeChange. – Anil Apr 11 '17 at 10:17