Hi firace
You are welcome
#EM_LINESCROLL has some drawbacks
Next is a better implementations
#1 :
Code: Select all
Enumeration
#EditArea
EndEnumeration
LoadFont(0,"Tahoma",12)
Window_1 = OpenWindow(#PB_Any, x, y, 554, 443, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
EditorGadget(#EditArea,0,0,WindowWidth(Window_1), WindowHeight(Window_1)-24)
SetGadgetFont(#EditArea,FontID(0))
For g = 1 To 300
initialtext$ + g + " LOVE PUREBASIC!" + #CRLF$
Next
SetGadgetText(#EditArea, initialtext$)
SetActiveGadget(#EditArea)
Row = 250
;SendMessage_(GadgetID(#EditArea),#EM_LINESCROLL,0,Row) ; this scrolls to Line 100 but does not place the caret there
index = SendMessage_(GadgetID(#EditArea),#EM_LINEINDEX,Row-1,0)
SendMessage_(GadgetID(#EditArea),#EM_SETSEL,index,index)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow : End
EndSelect
ForEver
#2 :
Code: Select all
Enumeration
#EditArea
EndEnumeration
Structure POINTL
x.l
y.l
EndStructure
LoadFont(0,"Tahoma",12)
Window_1 = OpenWindow(#PB_Any, x, y, 554, 443, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
EditorGadget(#EditArea,0,0,WindowWidth(Window_1), WindowHeight(Window_1)-24)
SetGadgetFont(#EditArea,FontID(0))
For g = 1 To 300
initialtext$ + g + " LOVE PUREBASIC!" + #CRLF$
Next
SetGadgetText(#EditArea, initialtext$)
SetActiveGadget(#EditArea)
index = SendMessage_(GadgetID(#EditArea),#EM_LINEINDEX,1,0)
SendMessage_(GadgetID(#EditArea),#EM_POSFROMCHAR,p.POINTL,index)
Row = 120
Rowh = p\y
CreateImage(0, 2, Rowh ,24)
StartDrawing(ImageOutput(0))
Box(0,0,2,Rowh,$F6F103)
StopDrawing()
;SendMessage_(GadgetID(#EditArea),#EM_LINESCROLL,0,Row) ; this scrolls to Line 100 but does not place the caret there
index = SendMessage_(GadgetID(#EditArea),#EM_LINEINDEX,Row,0)
SendMessage_(GadgetID(#EditArea),#EM_SETSEL,index,index)
SendMessage_(GadgetID(#EditArea),#EM_POSFROMCHAR,p.POINTL,index-1)
CreateCaret_(GadgetID(#EditArea),ImageID(0),0,0)
SetCaretPos_(0,p\y)
ShowCaret_(GadgetID(#EditArea))
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow : End
EndSelect
ForEver