Hello ArrogantCoder,
in order to move the scroll bar with the mouse you have to implement attachment. A scrollbar that is attached to the mouse cursor is moving in the same direction as the cursor, limited by the scrollbar's own bounds. The math behind it is pretty simple. You remember the (x,y) position of the cursor and of the scrollbar (in pixels) on click. We define the pixel position of the scrollbar as the top-most (vertical) or left-most (horizontal) pixel of it. Then for each mouse movement you calculate the new position:
new scrollbar pixel-pos = old-scrollbar-pixel-pos-at-click + ( current-cursor-pos - old-cursor-pos-at-click )
You only have to calculate one dimension: y dimension of vertical scrollbar, x dimension of horizontal scrollbar (scrollbar-pixel-dim)
Then you need to transform the new pixel position to scrollbar-percentage.
scrollbar-perc = min( 1, max( 0, scrollbar-pixel-dim / ( scrollbar-area-size-dim - scrollbar-size-dim ) ) )
where scrollbar-area-size-dim is the width of the horizontal scrollbar containment area, scrollbar-size-dim is the width of the scrollbar control that you can click on, scrollbar-area-size-dim >= scrollbar-size-dim (analogous definition for vertical scrollbar).
Feel free to ask if you have any further questions. ?
Other relevant information:
https://forum.multitheftauto.com/topic/132337-how-to-create-custom-guidashboard/?do=findComment&comment=1000972