Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Label-Caption more than 255 chars
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01642649
Message ID:
01642662
Views:
47
>Hi there,
>
>in a program I build dynamically a container filled with labels which contain Field-descriptions and values, somezjing like;
>
>Author: Some Author
>Tztle : Some Title
>
>I use labels set to a given width which is calculated during runtime amd autosize = .T. This works fine with wordwrapping
>but unfortunately the maximum size of the caption-property is 255 chars and some values are bigger. The edit-box has no autosize-property so I don not know how to handle this. Can someone give me some help how to handle this?
>
>Thanks in advance
>
>Thomas

This is some code from an application where we resized an edit box based on the string. maybe you can extract some of the code for yourself. I believe editbox is the way to go if your string exceeds 255 characters.
LPARAMETERS tcMessage
*
*-- The width and height of the font will be calculated with the fontmetric
*-- function. We first calculate the average width / height of one character.
lnAvgWidth  = FONTMETRIC( 6, THIS.edtMessage.FONTNAME, THIS.edtMessage.FONTSIZE, "N")
lnAvgHeight = FONTMETRIC( 1, THIS.edtMessage.FONTNAME, THIS.edtMessage.FONTSIZE, "N")
*
*-- The lines of the text are the occurances of the CHR(13) return string.
lnLinesCount = OCCURS(CHR(13), tcMessage) + 1
*
*-- Get the line with the longest text.
lnMaxLenght = 0
lnLastpos = 1
tcMessage = tcMessage + CHR(13)
FOR ln = 1 TO lnLinesCount
	lcItem = SUBST(tcMessage, lnLastPos, AT(CHR(13), tcMessage, ln) - lnLastPos)
	*
	*-- Is the number of chars of the longest line.
	lnMaxLenght = MAX(lnMaxLenght, LEN(lcItem))
	lnLastPos = AT(CHR(13), tcMessage, ln) + 1
ENDFOR
*
*-- Add an empty line at the beginning and at the end of the text if the text has only one line.
IF lnLinesCount = 1
		THIS.edtMessage.Value = SPACE(1) + CHR(13) + ;
				tcMessage + CHR(13) + SPACE(1) + CHR(13)
ELSE
	THIS.edtMessage.Value = tcMessage
ENDIF
*
*-- The lines count must be at least three lines.
lnLinesCount = MAX(lnLinesCount,3)
*
*-- Adjust the size of the label we add one to be sure to have enough space.
THIS.edtMessage.HEIGHT = lnAvgHeight * lnLinesCount + lnAvgHeight
*
*-- Is the number of chars of the longest line.
*-- Adjust the size of the label we add 25 to be sure to have enough space,
*-- think about capitalized text.
THIS.edtMessage.WIDTH  = lnAvgWidth * lnMaxLenght + lnAvgWidth + 50
*
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform