Page 1 of 1
stringgadget, autoscroll problem
Posted: Sat Aug 07, 2004 12:55 am
by newbie
Hi,
I have made simple
multiline string gadget like this :
Code: Select all
StringGadget(#String_0, 310, 10, 350, 140, "", #ES_MULTILINE | #ES_AUTOVSCROLL | #WS_VSCROLL | #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT)
So It is supposed to
scroll down automatically when text is added.
But when I do this :
Code: Select all
SetGadgetText(#String_0, GetGadgetText(#String_0) + Chr(13) + Chr(10) + "my text here")
The
scroll bar size on the right change, but it does not
scroll.
Worse, when I manually
scroll and that I add again text, I am bring back
to the start of the text 8O
Is there a way to have the text area to
scroll automatically to follow the text added ?
Posted: Sat Aug 07, 2004 7:16 pm
by newbie
ok below a complete code, to copy/paste & run :
Code: Select all
Enumeration
#Chat
#Button_1
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(0, 99, 153, 300, 150, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "test :")
If CreateGadgetList(WindowID())
StringGadget(#Chat, 30, 10, 200, 100, "", #ES_MULTILINE | #ES_AUTOVSCROLL | #WS_VSCROLL | #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT)
ButtonGadget(#Button_1, 30, 130, 70, 20, "Set")
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Repeat
EventID.l = WindowEvent()
If EventID = 0 ; We wait only when nothing is being done
Sleep_(20)
EndIf
Select EventID
Case #PB_Event_Gadget
Gadget = EventGadgetID()
Select Gadget
Case #Button_1
SetGadgetText(#Chat, GetGadgetText(#Chat) + Chr(13) + Chr(10) + "purebasic is fun!")
SetGadgetText(#Chat, GetGadgetText(#Chat) + Chr(13) + Chr(10) + "but unfortunaly")
SetGadgetText(#Chat, GetGadgetText(#Chat) + Chr(13) + Chr(10) + "the automatic scroll does nto work :(")
EndSelect
Case #PB_EventCloseWindow
Quit = 1
EndSelect
Until EventID <> 0
Until Quit = 1
you will see that the autoscroll does not work.
Press the "Set" button many times to see what I mean.
any idea why ?
Re: stringgadget, autoscroll problem
Posted: Sat Aug 07, 2004 7:36 pm
by GPI
newbie wrote:Code: Select all
StringGadget(#String_0, 310, 10, 350, 140, "", #ES_MULTILINE | #ES_AUTOVSCROLL | #WS_VSCROLL | #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT)
NEVER DO THIS THIS WAY! It work *NOT* on all Windows-Systems!
This work:
Code: Select all
Procedure EditorGadgetEnableTextWarp(Id); - Activate the automatic word-warp for a EditorGadget
GID=GadgetID(Id)
dc=GetWindowDC_(GID)
SendMessage_(GID, #EM_SETTARGETDEVICE ,dc ,-1)
ReleaseDC_(GID,dc)
EndProcedure
Posted: Sat Aug 07, 2004 8:27 pm
by newbie
Sorry to appears dumb, but I can't get it to work
Should I use it in addition or instead of ?
Should I put all of the constants in your procedure and nothing in the gadget creation ?
I am calling the procedure from the Window creation procedure, but if I remove the constants from the gadget creation I don't have anymore the
scroll bars

Posted: Sun Aug 08, 2004 10:21 pm
by newbie
Apparently I have to use an EditorGadget() and not a StringGadget(), that's why it didn't work.
Anyway I can't manage to have an editor gadget with :
- Vertival scrollbar ONLY
- when reaching the right automatically return to line, do not display an
horizontal bar
- scroll down automatically toward the bottom, to follow the text added
(and not manually scroll down every time)
Posted: Mon Aug 09, 2004 5:48 am
by PB
Hi newbie!
In your example, just put these lines after adding text to the
StringGadget:
Code: Select all
lines=SendMessage_(GadgetID(#Chat),#EM_GETLINECOUNT,0,0)
SendMessage_(GadgetID(#Chat), #EM_LINESCROLL, 0, lines)
This will make the
StringGadget scroll to the end of its contents.
Posted: Mon Aug 09, 2004 11:35 am
by newbie
Brilliant !
exactly what I was looking at !
Thanks you very much PB
