ISDBUIButtonEvents::OnClick: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
===Event description===
===Event description===


This event is called when button is clicked. You must use btn.Common.OnClick for the event to work properly.
This event is called when button is clicked.


If you want that Object is parsed with click use [[ISDBUICommonEvents::OnClick|Common OnClick event]] for the event to work properly.
===Example code===                   
<source lang="vb">
    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
</source>
[[Category:Scripting|{{PAGENAME}}]]
[[Category:Scripting|{{PAGENAME}}]]
[[Category:Automation objects|{{PAGENAME}}]]
[[Category:Automation objects|{{PAGENAME}}]]
[[Category:CoClass SDBUIButton|{{PAGENAME}}]]
[[Category:CoClass SDBUIButton|{{PAGENAME}}]]
[[Category:Interface ISDBUIButtonEvents|{{PAGENAME}}]]
[[Category:Interface ISDBUIButtonEvents|{{PAGENAME}}]]

Latest revision as of 21:16, 15 October 2012

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