Restored from previous forum. Originally posted by freak. Thanks, for the Tip, i needed that, too.
> Can somebody come up with a better way to restore the cursor position? Thanks!
Here we go...
Code:
; Dingless StringGadget example by PB -- do whatever you want with it.
; Shows how to avoid the "ding" sound when Esc/Enter is pressed on a StringGadget.
;
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
CreateGadgetList(WindowID())
sg=StringGadget(1,20,20,100,21,"",#PB_String_Multiline|#ES_AUTOVSCROLL)
ActivateGadget(1)
Repeat
ev=WaitWindowEvent()
If ev=#PB_EventGadget
a$=GetGadgetText(1) : pos=FindString(a$,Chr(13)+Chr(10),1)
If pos0 ; Was Enter pressed on the StringGadget?
SetGadgetText(1,ReplaceString(a$,Chr(13)+Chr(10),"")) ; Yes, so remove CR+LF.
SendMessage_(GadgetID(1), #EM_SETSEL, pos, pos) ; Set cursor Position
EndIf
EndIf
Until ev=#PB_EventCloseWindow
EndIf
Timo