Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Len()
Message
De
29/01/2015 01:15:58
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Len()
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614567
Message ID:
01614568
Vues:
50
>Here's the follow up to my previous enquiry
>I want to define the width of my temp window to match the longest sentence in this sample 3 line message
>In this case for example I need the code query to produce the number 31
>
>mes = 'I need the greatest line length'+chr(13)+chr(10)+'Of this 3 line message'+chr(13)+chr(10)+'any suggestions??'
>
>then I can use that length to define the width of the window that will open.
>(I hope i'm not regressing your coding experiences too far back.)
>
>tnx for your help
>
>k

As others suggested

It's not up to date to put a message in a temp window. At least not with ?.
One would use a form with editboxes etc. Calc the dimensions of the Edittbox, add some buttons and fit the form around.

If you realy need to let it look like a window, play around with the color* and border* properties.

But even for the editbox you would need to calculate the height - there is no autosize property. :)

You need to calculate width and high.
This depends on the len of the lines and the number of lines. Your friend is TXTWIDTH

For the height it's the height of a line + extra gap

So it needs to run the string line by line, get maximum lenght, number of lines * lineheight + gap

The gap is bit tricky

WIDTH see:
HELP TXTWIDTH
the height of a line is
  lnLineHeight = ;
   FONTMETRIC(1,.FONTNAME,.FONTSIZE,lcFontStyle)+;
   FONTMETRIC(5,.FONTNAME,.FONTSIZE,lcFontStyle)
n Lines => n * lnLineHeight

the gap is (for a given lnLineHeight)

WITH THIS
*CALCULATE the top-bottom-gap
lnOldHeight = .HEIGHT
llOldIntegralHeight = .INTEGRALHEIGHT

.HEIGHT = 2

*next three lines Start .INTEGRALHEIGHT
.FONTSIZE = .FONTSIZE-1
.INTEGRALHEIGHT = .T.
.FONTSIZE = .FONTSIZE+1
.INTEGRALHEIGHT = llOldIntegralHeight
*now we display exact one complete line in HEIGHT.

*one line is FONTMETRIC(1,...)+FONTMETRIC(5,...) + gap (figured out this rule manually)
*n lines is n*(FONTMETRIC(1,...)+FONTMETRIC(5,...)) + gap ( " )

*gap is .HEIGHT - (FONTMETRIC(1,...)+FONTMETRIC(5,...))
lnGap = .HEIGHT-lnLineHeight

.HEIGHT = lnOldHeight
ENDWITH &&THIS


HTH
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform