Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AutoSize (height) listbox?
Message
From
05/04/2000 15:22:17
 
 
To
24/03/2000 03:56:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00349273
Message ID:
00355875
Views:
27
Did you sort this?

This seems to do the trick:

LPARAMETERS toControl, tnRowCount
*-- Returns the rowheight or totalheight for the listbox control passed in
LOCAL lnReturn, lnTextHeight, lnExtraHeight, lcStyle

*-- Calculate Height Of Text
*-- First, What's the style?
lcStyle = IIF( toControl.FontBold, "B", "") + ;
IIF( toControl.FontItalic, "I", "") + ;
IIF( toControl.FontOutline, "O", "") + ;
IIF( toControl.FontShadow, "S", "") + ;
IIF( toControl.FontUnderline, "U", "") + ;
IIF( toControl.FontStrikeThru, "-", "")

lnTextHeight = FONTMETRIC( 1, toControl.FontName, toControl.FontSize, lcStyle)
lnExtraHeight = FONTMETRIC( 5, toControl.FontName, toControl.FontSize, lcStyle)

*-- Calculate RowHeight
*-- Fox adds 2 pixels to each row
lnReturn = ( lnTextHeight + lnExtraHeight + 2)

IF PCOUNT() = 2 AND VARTYPE( tnRowCount) = "N"
*-- Calculate total height of control
*-- All the rows, plus 2 for the top border and two for botton border
lnReturn = (lnReturn * tnRowCount) + 4
ENDIF

RETURN lnReturn




>Well I / you could (derive it) I expect, but I am adverse to using empirically derived formular unless necessary. But since no one has offered a proper solution it's looking that way. But I shall leave a decision till next week in case a better answer develops.
>Does your offer mean you have good insight into font metrics? I aways get lost in the world of leading / descenders etc when I return to font sizes!
>Thanks
>Dave
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform