Stringgadget Scroll to the end of text

Just starting out? Need help? Post your questions and find answers here.
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Stringgadget Scroll to the end of text

Post by em_uk »

Does anyone know how to get a stringgadget to scroll the the end? I have been trying #EM_SETSCROLLPOS but no joy.

Code: Select all


        OpenWindow(0,0,0,300,220,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

        StringGadget(2,20,140,260,26,"Enter your nameEnter your nameEnter your nameEnter your nameEnter your nameEnter your nameEND")

        p.POINT
        p\x=10
        p\y=0

        SendMessage_(GadgetID(2),#EM_SETSCROLLPOS,0,@p)
        
        SetActiveGadget(2)

        Repeat
            Event=WaitWindowEvent()

        Until Event=#PB_Event_CloseWindow
----

R Tape loading error, 0:1
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Stringgadget Scroll to the end of text

Post by Danilo »

Code: Select all

        OpenWindow(0,0,0,300,220,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

        StringGadget(2,20,140,260,26,"Enter your nameEnter your nameEnter your nameEnter your nameEnter your nameEnter your nameEND")

        len=Len(GetGadgetText(2))
        SendMessage_(GadgetID(2),#EM_SETSEL,len,len)
        SendMessage_(GadgetID(2),#EM_SCROLLCARET,0,0) ; not sure. maybe required on older systems?

        SetActiveGadget(2)

        Repeat
            Event=WaitWindowEvent()

        Until Event=#PB_Event_CloseWindow
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: Stringgadget Scroll to the end of text

Post by em_uk »

Damn it! I was fudging around with SETSEL just earlier. Thanks Danilo! :)
----

R Tape loading error, 0:1
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Stringgadget Scroll to the end of text

Post by Dude »

Danilo wrote:len=Len(GetGadgetText(2))
SendMessage_(GadgetID(2),#EM_SETSEL,len,len)
No need to use Len():

Code: Select all

OpenWindow(0,0,0,300,220,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

StringGadget(2,20,140,260,26,"Enter your name")

SendMessage_(GadgetID(2),#EM_SETSEL,-2,-1) ; Put cursor at end of StringGadget.

SetActiveGadget(2)

Repeat
  Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow
Post Reply