Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ListBox - autoresize
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00666161
Message ID:
00666508
Vues:
19
Hi Sebastian,

This seems to work fine:
with thisform
	.caption = m.tcCaption
	with .PopList
		.controlsource = m.tcControlSource
		.listindex = 1

		lcFontStyle = iif(.fontbold,"B","") + ;
			iif(.fontitalic,"I","")+ ;
			iif(.fontstrikethru,"-","")+ ;
			iif(.fontunderline,"U","")
          
		lnHeight = (fontmetric( 1, .fontname, .fontsize , m.lcFontStyle ) ;
			+ fontmetric( 5, .fontname, .fontsize , m.lcFontStyle ))
			
        lnWidth = txtwidth(m.lcText, .fontname, .fontsize , m.lcFontStyle ) * ;
			fontmetric( 6, .fontname, .fontsize , m.lcFontStyle )

		.height =  min((m.lnHeight+4.5 )*.listcount, _screen.height - thisform.top - 30)
		.width = min (m.lnWidth, _screen.width - thisform.left - 30)	
	endwith
	
	.height = .PopList.height  
	.width = .PopList.width 
endwith
Thanks again.


>Hi, Nadya!
>
>>>
>I was trying to use FontSize, but it's in points, and form's height in pixels. I sent this form to your e-mail address (clicked on envelope).
><<
>
>That's not a big deal - I dealed with those stuff at my 2.6 time a lot:
>To calculate with the metrics of a font - you have to use the FONTMETRIC() function!
>
>For the height of a line use
lnHeight = FONTMETRIC( 1, cFontName, nFontSize , cFontStyle ) ;
>            + FONTMETRIC( 5, cFontName, nFontSize , cFontStyle )
>For the width use
lnWidth = TXTWIDTH( m.MyText, cFontName, nFontSize , cFontStyle ) ;
>            * FONTMETRIC( 6, cFontName, nFontSize , cFontStyle )
>NOTE: Do never forget to specify all font parameters!
>
>BTW: FONTMETRIC( 5,...) is zero for a lot of fonts, but for some fonts not (this is an additional offset below the normal row of the characters!).
>
>NOTE: May be you have to add an another additional offset which is given due to a listbox specific gap between the lines. Make a screen shot, zoom it using Paint.exe to 800% and find it out <vbg>!
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform