I have a control that scrolls vertically. I need to calculate the position of the mouse (by click) relative to the top of the control, and not just the visible area.
For example, let's say my control has a height of 500. The scroll bar causes the visible rectangle to have a height of 100. Therefore, when I partially scroll, the client coordinate (from a mouse click) will return a number relative to the client rectangle (for example, 50).
But what I want to know is the offset from the beginning of my control, so it will be something like 250.
I tried to understand this for some time, and I think that I should lose sight of something simple, because I do not find much information on this topic.
Thank.
source
share