Home > Enterprise >  How to get the position of scrollbar thumb
How to get the position of scrollbar thumb

Time:08-18

I am trying to build a custom-scrollbar with winapi

example

To get Thumb length :

B / A = D / C

D = C * B / A

All fine so far. but struggling to find the Thumb position

example

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.

  • Related