Sample ListBox script

From MediaMonkey Wiki
Jump to navigation Jump to search
' This scripts shows how to easily use SDBUIListBox control for showing ordinary lists of strings. 

Dim lbl, LB

Sub OnStartUp()
  Dim Form

  Set Form = SDB.UI.NewForm
  Form.Common.SetRect 100, 100, 500, 440
  Form.BorderStyle = 3
  Form.FormPosition = 4
  Form.StayOnTop = True
  Form.Caption = "Test"

  Set lbl = SDB.UI.NewLabel(Form)
  lbl.Common.SetRect 10, 10, 400, 15

  Set LB = SDB.UI.NewListBox(Form)
  LB.Common.SetRect 10, 30, 400, 300
  LB.Items.Add "Item1"
  LB.Items.Add "Item2"
  Script.RegisterEvent LB, "OnChange", "VTChange"

  Set Btn = SDB.UI.NewButton(Form)
  Btn.Common.SetRect 10, 350, 80, 25
  Btn.Caption = "Add item"
  Script.RegisterEvent Btn, "OnClick", "BtnClick"

  Form.Common.Visible = True

  SDB.Objects("Form") = Form
End Sub

Sub VTChange( Control)
  lbl.Caption = Control.ItemIndex
End Sub

Sub BtnClick
  LB.Items.Add "New item"
End Sub