ISDBUIButtonEvents::OnClick

From MediaMonkey Wiki
Jump to navigation Jump to search

CoClass SDBUIButton, Interface ISDBUIButtonEvents

Sub OnClick


Event description

This event is called when button is clicked.

If you want that Object is parsed with click use Common OnClick event for the event to work properly.

Example code

    Sub OnStartup
      Set UI = SDB.UI

      ' Create the window to be shown
      Set Form = UI.NewForm
      Form.FormPosition = 4   ' Screen Center
      Form.Caption = "Test Change labels"

      Set Lbl2 = UI.NewLabel(Form)
      Lbl2.Common.ControlName = "Lbl2"
      Lbl2.Common.SetRect 10, 10, 100, 16
      Lbl2.Caption = "Change This Label"

      SDB.Objects("MyLbl2") = Lbl2

      Set Btn2 = UI.NewButton(Form)
      Btn2.Common.ControlName = "Btn2"
      Btn2.Common.SetRect 10, 40, 80, 25
      Btn2.Caption = "Test"
      Script.RegisterEvent Btn2, "OnClick", "Btn2Click"

      Form.ShowModal

    End Sub

    Sub Btn2Click
      Set label2 = SDB.Objects("MyLbl2")
      label2.Caption = "Label Changed"

      'SDB.MessageBox "Clicked Button", mtInformation, Array(mbOk)
      ' add code to change Caption of Lbl2
    End Sub