Suggest gadget for scrolling status window?

Just starting out? Need help? Post your questions and find answers here.
pthien
Enthusiast
Enthusiast
Posts: 150
Joined: Sun Jun 29, 2003 9:39 pm

Suggest gadget for scrolling status window?

Post by pthien »

I'm learning PureBasic by playing with the Atomic Web Server. I'm trying to add a Window which shows the date, time, client IP, and filename sent to clients. I've started by using the ListViewGadget for this.

I don't really need to be able to have users click on these items, though, as ListViewGadget supports. I would also like to keep appending things to the top of the gadget and scroll old items off the bottom, or add lines to the bottom of the gadget but keep the gadget scrolling upward, so the newest line is always visible and the oldest line is scrolled out of visibility.

Any suggestions about a better way to implement this? What Gadget would work better, for example? Or, if the ListViewGadget is best, is there a way to prevent users from being able to click on lines and make certain the scrolling I'm looking for is achieved?

Thanks,
Phil
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

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(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 | #PB_String_ReadOnly)
      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
Something like that...
--Kale

Image
Post Reply