Difference between revisions of "ISDBUI::AddPropertiesSheet"

From MediaMonkey Wiki
Jump to: navigation, search
 
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{MethodDeclaration|SDBUI|ISDBUI|Function AddPropertiesSheet(SheetLabel As String, ScriptFile As String, InitProcedure As String, TrackChangeProcedure As String, SaveProcedure As String) As Long}}
+
{{MethodDeclaration|SDBUI|ISDBUI|Function AddPropertiesSheet(SheetLabel As String, ScriptFile As String, InitProcedure As String, TrackChangeProcedure As String, SaveProcedure As String, Order As Integer) As Long}}
  
 
===Parameters===
 
===Parameters===
Line 8: Line 8:
 
  |InitProcedure |String |A function from ScriptFile that is called when Properties dialog is created. There is one parameter present - a reference to the sheet ([[SDBUITranspPanel]] object)
 
  |InitProcedure |String |A function from ScriptFile that is called when Properties dialog is created. There is one parameter present - a reference to the sheet ([[SDBUITranspPanel]] object)
 
  |TrackChangeProcedure |String |A function from ScriptFile that is called when track(s) are changed. Track(s) for those the properties are shown. There are two parameters presented - a reference to the tracks object ([[SDBSongData]] or [[SDBSongList]] object), object type identifier (0 - Object is [[SDBSongData]], 1 - Object is [[SDBSongList]])
 
  |TrackChangeProcedure |String |A function from ScriptFile that is called when track(s) are changed. Track(s) for those the properties are shown. There are two parameters presented - a reference to the tracks object ([[SDBSongData]] or [[SDBSongList]] object), object type identifier (0 - Object is [[SDBSongData]], 1 - Object is [[SDBSongList]])
  |SaveProcedure |String |A function from ScriptFile that is called when edited tracks(s) are to be saved (closed by OK button). There are three parameters presented - a reference to the sheet ([[SDBUITranspPanel]] object), a reference to the tracks object ([[SDBSongData]] or [[SDBSongList]]), object type identifier (0 - Object is [[SDBSongData]], 1 - Object is [[SDBSongList]])}}
+
  |SaveProcedure |String |A function from ScriptFile that is called when edited tracks(s) are to be saved (closed by OK button). There are three parameters presented - a reference to the sheet ([[SDBUITranspPanel]] object), a reference to the tracks object ([[SDBSongData]] or [[SDBSongList]]), object type identifier (0 - Object is [[SDBSongData]], 1 - Object is [[SDBSongList]])
 +
|Order |Integer | Order (Page index) of the newly added sheet. If the value is out of range (like -1) then the sheet is added as the last (rightmost).}}
  
 
===Method description===
 
===Method description===
Line 14: Line 15:
 
Creates a new sheet that appears in Properties dialog.
 
Creates a new sheet that appears in Properties dialog.
  
MediaMonkey 4.0
+
{{Introduced|4.0}}
  
 
===Example code===                     
 
===Example code===                     
Line 22: Line 23:
  
 
Sub OnStartUp
 
Sub OnStartUp
Dim i : i = SDB.UI.AddPropertiesSheet("Sample sheet", Script.ScriptPath, "InitSheet", "TrackChange", "SaveSheet")
+
Dim i : i = SDB.UI.AddPropertiesSheet("Sample sheet", Script.ScriptPath, "InitSheet", "TrackChange", "SaveSheet", 2)
 
End Sub
 
End Sub
  
Line 86: Line 87:
 
===Related Topics===
 
===Related Topics===
  
*[[Sample Properties Sheets script]]
+
*[[Possible properties sheet values]]
  
 
[[Category:Scripting|{{PAGENAME}}]]
 
[[Category:Scripting|{{PAGENAME}}]]

Latest revision as of 21:15, 20 April 2013

CoClass SDBUI, Interface ISDBUI

Function AddPropertiesSheet(SheetLabel As String, ScriptFile As String, InitProcedure As String, TrackChangeProcedure As String, SaveProcedure As String, Order As Integer) As Long


Parameters

Name Type Description
SheetLabel String A label that appears in the tab list of properties sheets (sheet name).
ScriptFile String A script file that contains event functions (InitProcedure, TrackChangeProcedure and SaveProcedure).
InitProcedure String A function from ScriptFile that is called when Properties dialog is created. There is one parameter present - a reference to the sheet (SDBUITranspPanel object)
TrackChangeProcedure String A function from ScriptFile that is called when track(s) are changed. Track(s) for those the properties are shown. There are two parameters presented - a reference to the tracks object (SDBSongData or SDBSongList object), object type identifier (0 - Object is SDBSongData, 1 - Object is SDBSongList)
SaveProcedure String A function from ScriptFile that is called when edited tracks(s) are to be saved (closed by OK button). There are three parameters presented - a reference to the sheet (SDBUITranspPanel object), a reference to the tracks object (SDBSongData or SDBSongList), object type identifier (0 - Object is SDBSongData, 1 - Object is SDBSongList)
Order Integer Order (Page index) of the newly added sheet. If the value is out of range (like -1) then the sheet is added as the last (rightmost).


Method description

Creates a new sheet that appears in Properties dialog.

Introduced in MediaMonkey version 4.0.


Example code

Option Explicit

Sub OnStartUp
	Dim i : i = SDB.UI.AddPropertiesSheet("Sample sheet", Script.ScriptPath, "InitSheet", "TrackChange", "SaveSheet", 2)
End Sub

Sub InitSheet(Sheet)
	Dim UI : Set UI = SDB.UI
	Dim ini : Set ini = SDB.IniFile
	
	Dim a : Set a = UI.NewGroupBox(Sheet) : a.Caption = "Settings" : a.Common.SetRect 10, 10, 230, 210

  Dim ch
  Set ch = UI.NewCheckbox(a)
  ch.Common.SetRect 15, 20, 250, 20
  ch.Common.ControlName = "CheckBox1" 
  ch.Caption = "Update to ini file"
  ch.Checked = true
  
  Dim e
  Set e = UI.NewEdit(a)
  e.Common.SetRect 15, 50, 250, 50
  e.Common.ControlName = "EditBox1"
  e.Text = "Song Title"
  e.Common.Enabled = True
  
  SDB.Objects("EditBox1") = e

End Sub

Sub TrackChange( Object, ObjectType)
  Dim e: Set e = SDB.Objects("EditBox1")
  
  If ObjectType = 0 then ' it is just Song 
    e.Text = Object.Title
  End If
    
  If ObjectType = 1 then ' it is SongList
    e.Text = Object.Count & " songs selected"
  End If
  
End Sub

Sub SaveSheet(Sheet, Object, ObjectType)
	Dim ini : Set ini = SDB.IniFile

  If ObjectType = 0 then ' it is just Song 
    If Sheet.Common.ChildControl("CheckBox1").Checked then
      ini.StringValue("SampleScript", "Updated Song") = Object.Title
    End If   
  End If  
   
  If ObjectType = 1 then ' it is SongList   
    If Sheet.Common.ChildControl("CheckBox1").Checked then
      Dim i   
      For i = 0 to Object.Count-1
        ini.StringValue("SampleScript", "Updated Songs - Song " & i ) = Object.Item(i).Title
	    Next 
    End If     
  End If   
  
End Sub

Related Topics