Sample Dockable panels script

From MediaMonkey Wiki
Jump to: navigation, search
' This script shows how you can create new panels on the main window, put any content 
' in them, react to currently selected and played tracks, etc. The panel even persists
' its position after restart of MediaMonkey. 
Dim Mnu, Pnl, Lbl, Lbl2 
Sub OnStartup 
  Set UI = SDB.UI 
  Set Pnl = UI.NewDockablePersistentPanel("TestingPanel") 
  if Pnl.IsNew then 
    Pnl.DockedTo = 2 
    Pnl.Common.Width = 250 
  end if 
  Pnl.Caption = "My test" 
  Script.RegisterEvent Pnl, "OnClose", "PnlClose" 
  Set Lbl = UI.NewLabel(Pnl) 
  Lbl.Autosize = false 
  Lbl.Multiline = true 
  Lbl.Common.SetRect 10, 10, Pnl.Common.Width-20, Pnl.Common.Height-20 
  Lbl.Common.Anchors = 15  '1+2+4+8 
  ' Add menu item that shows panel after it is closed 
  Set Sep = SDB.UI.AddMenuItemSep(SDB.UI.Menu_View,0,0) 
  Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View,0,0) 
  Mnu.Caption = "My testing panel" 
  Mnu.Checked = Pnl.Common.Visible 
  Script.RegisterEvent Mnu, "OnClick", "ShowPanel" 
  Script.RegisterEvent SDB, "OnChangedSelection", "OnSelection" 
End Sub 
Sub ShowPanel(Item) 
  Pnl.Common.Visible = not Pnl.Common.Visible 
  Mnu.Checked = Pnl.Common.Visible 
End Sub 
Sub PnlClose( Item) 
  Mnu.Checked = false 
End Sub 
Sub OnSelection 
  Lbl.Caption = "Selected tracks: " & SDB.CurrentSongList.Count 
End Sub