Difference between revisions of "ISDBUIButtonEvents::OnClick"

From MediaMonkey Wiki
Jump to: navigation, search
 
(Event description)
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
This event is called when button is clicked.
 
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