Hi,
I have a multiline stringgadget and when the user does something usery (ie: stupid) it produces an error messagerequester..
Now, when the user leaves the messagerequester and i return the user to the stringgadget (after removing the error from the stringgadget, as they were dumb and made the error), i can get the cursor to move to the bottom of the stringgadget without problem..
However, the stringgadget resets it's scrolling to the top of the stringgadget..
How do i scroll the gadget down to the bottom again from code?
Timmy
Multi-line StringGadget and 'going to the bottom'
Re: Multi-line StringGadget and 'going to the bottom'
> the stringgadget resets it's scrolling to the top of the stringgadget
I can't get a StringGadget to do that after a MessageRequester... can you post
some code that demonstrates it? (When I tried it, the StringGadget didn't scroll
anywhere).
I can't get a StringGadget to do that after a MessageRequester... can you post
some code that demonstrates it? (When I tried it, the StringGadget didn't scroll
anywhere).
Code: Select all
win = OpenWindow(1,10,10,200,200,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered,"TEST")
If CreateGadgetList(WindowID())
StringGadget(string_6,10,10,50,50,"",#PB_String_Multiline|#WS_VSCROLL)
EndIf
Repeat
EventID.l = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadgetID()
Case string_6
newline = FindString(GetGadgetText(String_6),Chr(13) + Chr(10),1)
If newline <> 0
lcnt = CountString(GetGadgetText(String_6),Chr(13) + Chr(10))
If lcnt + 1 > 5
txt$ = GetGadgetText(String_6)
txt$ = Left(txt$,Len(txt$) - 2)
SetGadgetText(String_6,txt$)
SendMessage_(GadgetID(String_6), #EM_SETSEL, Len(GetGadgetText(String_6)), Len(GetGadgetText(String_6)))
MessageRequester("OOPS","The amount of lines exceeds" + Chr(10) + "the maximum length of " + Str(5) + " lines!")
EndIf
EndIf
EndSelect
EndSelect
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
Timmy
Just stick this in before your current SendMessage line:
BTW, it wasn't the MessageRequester causing the problem, it was SetGadgetText.
Code: Select all
SendMessage_(GadgetID(String_6), #EM_LINESCROLL, 0, 5)