EnableExplicit

Define EventID
Define a

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(1, 0, 0, WindowWidth(0), WindowHeight(0)-40, "Spalte", 450, 0)
  For a=1 To 100
    AddGadgetItem(1, -1, "Item " + Str(a), 0, 0)
  Next
  
  ButtonGadget(2, WindowWidth(0)-210, WindowHeight(0)-30, 200, 20, "Erste sichtbare Zeile ermitteln", 0)
  
  Repeat
    EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget
      Select EventGadget()
        Case 2
          Debug SendMessage_(GadgetID(1), #LVM_GETTOPINDEX, 0, 0)
      EndSelect
    EndIf
    If EventID = #PB_Event_CloseWindow
      End
    EndIf
  ForEver
EndIf