@daolix
Thank you so much.
I've tried the code on a variety of font names, tried bold/italic/underline & all sizes from 1pt to 72pt (although most of those sizes are obviously ridiculous for a listbox)
It works brilliantly!
Only italic makes any difference to font height so my form 5 now has the choice of
a) 13 standard Windows fonts
b) point sizes 7 to 14 pt
c) italic - yes/no
One part of the Wizhook code doesn't make sense to me:
Code:
LBRH = (ly And Not &HFFFF0000) + 30 - 15
I believe that's a colour hex value so why is it there?
I tested the results with & without it - they were identical - so i've removed it
So I've simplified the code to:
Code:
WizHook.Key = 51488399
Dim lx As Long 'width of font caption tested
Dim ly As Long 'height of font caption tested
'caption tested = "W" - height only needed for testing
With Me.lstImages
If WizHook.TwipsFromFont(.FontName, .FontSize, .FontWeight, .FontItalic, .FontUnderline, 0, "W", 0, lx, ly) = True Then
LBRH = ly + 15 'height + 15 twips (1px) as 1 px left between each listbox row
End If
End With
I would very much like to know where you heard about Wizhook & whether it has other examples of its use beyond those in the links I provided earlier