I need to manipulate text selections and want to restore the old state at the end.
So I saved the old state with EM_EXGETSEL and at the end I set it again with EM_EXSETSEL.
Now the problem:
If I mark a part of the text with the mouse from left to right everything is fine.
If I mark it from right to left I loose the end point of the marking.
Code to test:
Code: Select all
EnableExplicit
Define.i Event, Selection.CHARRANGE
OpenWindow(0, 0, 0, 400, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 10, 10, 380, 280)
SetGadgetText(0, "The quick brown fox jumps over the lazy dog")
AddWindowTimer(0, 1, 250)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Timer
If EventTimer() = 1
SendMessage_(GadgetID(0), #EM_EXGETSEL, 0, @Selection)
Debug "Selection from " + Str(Selection\cpMin) + " to " + Str(Selection\cpMax)
; I do some stuff here with #EM_EXSETSEL
SendMessage_(GadgetID(0), #EM_EXSETSEL, 0, @Selection)
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
Btw.: PB 5.61 x86 on Win 10 x64
Bernd