Page 1 of 1
Stringgadget question
Posted: Mon May 12, 2003 8:02 pm
by aszid
is there a simple way to make a stringgadget stay scrolled down at the bottom?
i'm working on a chat client, and i'm using a read-only string-gadget for the conversation text, but the only way i know to add to it is by re-writing all of the text to the gadget. The problem being that when i do that, the window is scrolled to the top, leaving the latest text at the bottom, which needs to be scrolled to.
any suggestions would be appreciated.
thanks in advance,
Aszid
Posted: Mon May 12, 2003 8:16 pm
by Andre
If it should read-only: how about using ListViewGadget() and SetGadgetState() for setting the last item as active one? (I know, only a quick and dirty solution...

)
Posted: Mon May 12, 2003 8:22 pm
by Kale
use a listview gadget and use this:
Code: Select all
SetGadgetState(#LISTVIEW_GADGET, CountGadgetItems(#LISTVIEW_GADGET)-1)
Posted: Mon May 12, 2003 8:28 pm
by aszid
hmm... i considered doing that, but i want to keep copy-paste functionality for the window, and i'm relatively sure you can't select just a portion of a line with a listviewgadget.
i was hoping for a quick flag or something that i could add at gadget creation that would make it stay at the bottom... but alas... maybe i'll go suggest that in the feature request thread.
Posted: Mon May 12, 2003 9:17 pm
by Kale
try this:
Code: Select all
#Window_0 = 0
#Gadget_0 = 0
#Gadget_1 = 1
#Gadget_2 = 2
Procedure AddText()
exsistingText.s = GetGadgetText(#Gadget_0)
If exsistingText = ""
SetGadgetText(#Gadget_0, GetGadgetText(#Gadget_1))
Else
SetGadgetText(#Gadget_0, exsistingText + Chr(13) + Chr(10) + GetGadgetText(#Gadget_1))
EndIf
lines = SendMessage_(GadgetID(#Gadget_0),#EM_GETLINECOUNT,0,0)
SendMessage_(GadgetID(#Gadget_0), #EM_LINESCROLL, 0, lines)
EndProcedure
If OpenWindow(#Window_0, 338, 281, 439, 254, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "New window ( 0 )")
If CreateGadgetList(WindowID())
StringGadget(#Gadget_0, 5, 5, 430, 210, "", #ES_MULTILINE | #ES_AUTOVSCROLL | #ES_AUTOHSCROLL | #WS_VSCROLL | #WS_HSCROLL)
StringGadget(#Gadget_1, 5, 225, 345, 21, "")
ButtonGadget(#Gadget_2, 358, 222, 77, 25, "Enter >>>")
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_EventGadget
Select EventGadgetID()
Case #Gadget_2
AddText()
EndSelect
EndSelect
Until Event = #PB_EventCloseWindow
End
Posted: Mon May 12, 2003 9:43 pm
by aszid
awesome!
thanks alot for the help, i only needed 2 lines of the code, but those 2 work perfectly.
i REALLY love the community that purebasic has, i asked a question, and within a few hours 3 people made suggestions for me.
Professional technical support is nowhere near the quality that the community provides here.
Posted: Sat Aug 16, 2003 1:30 am
by aszid
i found a better way to do this, so i thought i'd share with the forums.
this works on editorgadgets... haven't tried it on anything else.
all you need to do... is replace these 2 lines:
Code: Select all
lines = SendMessage_(GadgetID(#Gadget_0),#EM_GETLINECOUNT,0,0)
SendMessage_(GadgetID(#Gadget_0), #EM_LINESCROLL, 0, lines)
with this one line:
Code: Select all
SendMessage_(GadgetID(#Gadget_0), #EM_SCROLLCARET, 0,0)