I am trying to build a custom-scrollbar with winapi
To get Thumb length :
B / A = D / C
D = C * B / A
All fine so far. but struggling to find the Thumb position
Given an (viewport) offset, how to get the thumb offset? Or any suggestions?
CodePudding user response:
First, your thumb size calculation contains an error - rearranging valid proportion A / B = C / D
, thumb size is D = C * B / A
, not D = C * A / B
.
Regarding offset calculation, proportion can be constructed in a similar way since track C
represents whole content A
and thumb offset F
represents viewport offset E
. So, A / C = E / F
, from which, rearranging, we get F = E * C / A
.