Scroll (Window)

Just starting out? Need help? Post your questions and find answers here.
arma
User
User
Posts: 61
Joined: Sun Jul 24, 2016 11:54 pm

Scroll (Window)

Post by arma »

I want to scroll window to top... For example wşth this code, I always want to see the top of window... Is there any command to move the scroll of window...

Code: Select all

If OpenWindow(0,0,0,305,140,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(0,10,10,285,120)
  For t=1 To 50
    AddGadgetItem(0,0,Str(t))
    a=ElapsedMilliseconds()
    Repeat
      WaitWindowEvent(100)
    Until ElapsedMilliseconds()-a>499
  Next t
EndIf
Thanks!

// Edit: Code formatted and code tags added (Kiffi)
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Scroll (Window)

Post by infratec »

Please use the code tags, this makes it easier to see the code of your post.
And I think your question is wrong.

I think you want always to see the top of the ListView and not the top of the window.
And I don't know how to scroll a window :wink:

Since I'm not 100% sure what you want, you have to comment/uncomment to see the differences:

Code: Select all

If OpenWindow(0,0,0,305,140,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(0,10,10,285,120)
    
  AddWindowTimer(0, 1, 100)
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Timer
      If t = 50
        RemoveWindowTimer(0, 1)
      Else
        AddGadgetItem(0, 0, Str(t))
        ;AddGadgetItem(0, -1, Str(t))
        SetGadgetState(0, t)
        t + 1
      EndIf
    EndIf
    
  Until Event = #PB_Event_CloseWindow
EndIf
arma
User
User
Posts: 61
Joined: Sun Jul 24, 2016 11:54 pm

Re: Scroll (Window)

Post by arma »

Your code doesnt work for me...
I mean... I want to see always the top of the window... When i add new item, i want to see always th top of the windows... I mean want to see the last item.
By the way; I dont know if we see each the similar (same i mean) I use Ubuntu version, Ubuntu 20.04. I see always "0" line...
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Scroll (Window)

Post by Saki »

Hi, try this
I have to time not linux installed, so i can not test it
But on Linux it is a little other with the events

Code: Select all

If OpenWindow(0,0,0,305,140,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(0,10,10,285,120)
   
  AddWindowTimer(0, 1, 100)
 
  Repeat
    Event = WaitWindowEvent()
   
    If Event = #PB_Event_Timer
      If t = 50
        RemoveWindowTimer(0, 1)
      Else
        AddGadgetItem(0, 0, Str(t))
        ;AddGadgetItem(0, -1, Str(t))
        SetGadgetState(0, t)
        t + 1
      EndIf
      While WindowEvent() : Wend
    EndIf
   
  Until Event = #PB_Event_CloseWindow
EndIf
地球上の平和
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Scroll (Window)

Post by RASHAD »

Hi
Maybe

Code: Select all

If OpenWindow(0,0,0,305,140,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(0,10,10,285,120)
  For t=1 To 50
    AddGadgetItem(0,0,Str(t))
    a=ElapsedMilliseconds()
    SetGadgetState(0, t-1)
    SetGadgetState(0, -1)
    Repeat     
      WaitWindowEvent(100)     
    Until ElapsedMilliseconds()-a>499       
  Next t
EndIf
Egypt my love
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Scroll (Window)

Post by infratec »

You want to see always the top of the ListView and not of the window.

And I told you you have to play with the comments, since it was not clear what you really want.

So I played with the comments:

Code: Select all

If OpenWindow(0,0,0,305,140,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListViewGadget(0,10,10,285,120)
   
  AddWindowTimer(0, 1, 100)
 
  Repeat
    Event = WaitWindowEvent()
   
    If Event = #PB_Event_Timer
      If t = 50
        RemoveWindowTimer(0, 1)
      Else
        AddGadgetItem(0, 0, Str(t))
        ;AddGadgetItem(0, -1, Str(t))
        SetGadgetState(0, 0)
        t + 1
      EndIf
    EndIf
   
  Until Event = #PB_Event_CloseWindow
EndIf
arma
User
User
Posts: 61
Joined: Sun Jul 24, 2016 11:54 pm

Re: Scroll (Window)

Post by arma »

Thank you...
Last One Works for me... Thank you AGAIN!
Post Reply