Simple line wrap for a message box
When message is too long VFP message box provides a line wrap but it stretches out almost of the with of the screen. It's easy to implement a line wrap to specified number of characters using VFP memo handling capabilities.
$SAMPLECODE$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 lcText = "Is there any way to limit the width of a messagebox? " + CHR(13) + ; "In other words, if I pass a rather long message as the message text, " + ; "rather than the messagebox stretching out the width of my screen, " + ; "I'd like it to display only about 70 characters per line " + ; "and do word wrap on anything longer." * A message box line wrap MESSAGEBOX(lcText, 0, "A message box line wrap" ) lnMaxLineLen = 72 * Save current setting lnMemowith = SET("Memowidth") SET MEMOWIDTH TO (lnMaxLineLen) lcNewText = "" FOR i=1 TO MEMLINES(lcText) lcNewtext = lcNewText + ALLTRIM(MLINE(lcText,i)) + CHR(13) ENDFOR lcNewtext = LEFT(lcNewtext, LEN(lcNewtext )-1) * Restore previous setting SET MEMOWIDTH TO (lnMemowith) * Line wrap to the specified # of characters MESSAGEBOX(lcNewtext, 0, "Up to " + TRANSFORM(lnMaxLineLen ) + " characters per line" )
Comments