Thanks for those comments Ajax which I fully agree with
Surprisingly perhaps the code does work if there are more records in the listbox than fit the available space
FWIW I did make a mistake in the code and correcting it does significantly reduce though not completely eliminate the discrepancy
I wrote that the code should add 3pt to the font size but in testing I changed it to +2
So alter it as shown in BOLD RED text in form 4
Code:
Private Function GetListboxRowHeight()
......
'My observations
'Add 3pt to font point size and use function converttoTwipsYFromPoint(point size)
'Then add +15 twips for each row (1px) ONLY IF font size is odd value
'For row 1 - add a further 45 twips (3px)
.......
'get listbox row height in twips
'Typically a listbox row is the height of capital A with +3pt eg. 11pt font =>14
'This gives approx correct answer - works well at 11/12pt - slightly less so at more extreme values
LBFS = Me.lstContacts.FontSize + 3
LBRH = converttoTwipsYFromPoint(LBFS)
End Function
Do EXACTLY the same changes in Form 5
Another part of the issue is that whilst its logical to assume the cursor arrowhead is where the cursor actually is, that may not actually be true
I experimented changing the cursor arrow to an I-beam or <--> shape and the issue was almost entirely resolved
However I can't get this cursor shape to work consistently reliably at the moment and, to some extent, flickering returns.
So I've abandoned that idea for now
Finally another issue unrelated to my code. There is a slight latency between moving the mouse & that change showing on the screen
So there is brief gap between the actual cursor position calculated by Windows & that shown on the screen.
You'll see what I mean of you test when the CPU is under heavy load and struggling a bit for any reason.
There is nothing I can do about that other than buy myself a new PC