stringgadget, autoscroll problem

Just starting out? Need help? Post your questions and find answers here.
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

stringgadget, autoscroll problem

Post 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 ?
- Registered PB user -

Using PB 4.00
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post 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 ?
- Registered PB user -

Using PB 4.00
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: stringgadget, autoscroll problem

Post 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
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post by newbie »

Sorry to appears dumb, but I can't get it to work :oops:
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
:?
- Registered PB user -

Using PB 4.00
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post 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)
- Registered PB user -

Using PB 4.00
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
newbie
Enthusiast
Enthusiast
Posts: 296
Joined: Tue Jul 29, 2003 5:47 pm
Location: FRANCE
Contact:

Post by newbie »

Brilliant !

exactly what I was looking at ! :D

Thanks you very much PB :P
- Registered PB user -

Using PB 4.00
Post Reply