Re: Word wrapping a string to arbitrary position?
Posted: Mon Mar 04, 2013 5:15 pm
Hi Fangles
Why bother yourself if windows can do the job for you
Final Text$ is your aim
Edit :Now it is more accurate
Why bother yourself if windows can do the job for you
Final Text$ is your aim
Code: Select all
If OpenWindow(1, 40, 40, 400, 460, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 10, 40, 380, 200)
EditorGadget(2, 10, 250, 380, 200)
SendMessage_(GadgetID(1), #EM_SETTARGETDEVICE, #Null, 0)
ButtonGadget(3,10,10, 80, 24, "Test Output")
Text$ = "This is another long line of text to see if scrollbars come up automatically.This is another long line of text to see if scrollbars come up automatically.This is another long line of text to see if scrollbars come up automatically"
width = 380
RLL = 30
SetGadgetText(1, Text$)
For x = 1 To 100
oldll = 0
For x = 0 To CountGadgetItems(1) - 1
LLength = Len(GetGadgetItemText(1, x))
If LLength > Oldll
oldll = llength
EndIf
Next
Debug oldll
If oldll > RLL -1 And (rll - oldll) <> 0
width = width - (oldll - RLL)*2
ClearGadgetItems(1)
ResizeGadget(1,10,40,width,200)
SetGadgetText(1, Text$)
Else
Break
EndIf
Next
Repeat
Event=WaitWindowEvent(1)
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 3
Text$ = GetGadgetItemText(1, 0)
For x = 1 To CountGadgetItems(1) - 1
GetGadgetItemText(1, x)
Text$ =Text$+#CRLF$ + GetGadgetItemText(1, x)
Next
SetGadgetText(2, Text$)
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
EndIf