I have a text box that contains verbage that will wrap. Unfortunately, the text does not save where it actually wrapped. Therefore, when I am trying to use OIPI to print the text it does not wrap in the same place.
This is sort of like WYSINWYG (What you see is Not what you get).
Idealy, it would be nice to be able to identify where the text wrapped on the control and save that info with the text.
Any ideas?
Thanks,
John
Never mind, I found a way around the issue that will work.
John,
Never mind, I found a way around the issue that will work.
Just as I was about to make you a reply.
Anyway… I don't know of an easy way to find the break points. With Utility "TEXTRECT" you can find out how wide and tall a certain text in a certain font becomes when displayed within a certain width. A very crude method to find the points where the text breaks could be to do loop n=1, 2, 3, etc, with Utility "TEXTRECT" on the first n characters of the text. When the height you get back from Utility increases from one character to the next there is a break point.
So actually it isn't so difficult but it's not very elegant.
(For more details do a search on Utility and TEXTRECT and Bakke.)
You can find the same functionality as Utility "TEXTRECT" in OIPI's Get_Printer/Set_Printer "CALCTEXT". So you can do the same calculations in OIPI if that suits you better.
- Oystein -
Thanks for the reply!
I just figured that it wasn't as important as I initialy thought to determine where the text wraps. The client will have to test the final output and if they are unhappy then they can always go back in and press the enter key where they want a new line.
Your solution does sound interesting though!
Thanks,
John Bouley
John,
If you really want to know where the text actually wraps, ya might want this code. "LINE" is the line you want the info on. "START_POS" is the character position of the text that the line starts on. Remember these are zero-based indexes.
DECLARE FUNCTION SENDMESSAGE
EM_LINEINDEX=187
EM_LINELENGTH=193
HANDLE=GET_PROPERTY(CTRLENTID,'HANDLE')
LINE=2 - 1
START_POS=SENDMESSAGE(HANDLE,EM_LINEINDEX,LINE,0)
Look for EM_LINEINDEX.