VBA userforms, and listviews in particular, are tricky when it comes to spatial distances and coordinates. The question I am trying to solve is: the mousedown event gives the coordinates in pixles - how do I transform that into the units required for repositioning another user control and also incorporate the width property of user controls.
To give the very specific problem: I have a listview with multiple columns and a horizontal scroll bar. I want to get the selected row and column of the mouse click and then reposition a frame to the point at which the mouse was clicked.
Googling only came up with partial answers - nothing solving the full problem.
There are three different units of measurement. Pixels, twips and imperial points.
Once you have gotten your functions/subs down to convert between pixels, twips and imperial points, you can then use the correct coordinate units for each different task:
MouseDown
event gives the coordinates in pixels.HitTest
(the listview function to return the selected row -
although not the selected column) takes coordinates in twips.GetScrollPos
(the Windows API function to return the scrollbar
position) gives a value in pixels.