Sample Events for User Interface script
Jump to navigation
Jump to search
' This scripts shows how event support can be used to create dialogs that better
' react to user actions. Not that the button there is enabled only if checkbox is checked, etc.
Sub OnStartup
Set UI = SDB.UI
' Create the window to be shown
Set Form = UI.NewForm
Form.Common.SetRect 100, 100, 500, 400
Form.FormPosition = 4 ' Screen Center
Form.Caption = "Test"
Script.RegisterEvent Form.Common, "OnResize", "FormResize"
Set Lbl = UI.NewLabel( Form)
Lbl.Common.ControlName = "Lbl"
Lbl.Common.SetRect 10, 10, 100, 16
Set ChB = UI.NewCheckBox( Form)
ChB.Common.ControlName = "ChB"
ChB.Common.SetRect 10, 50, 100, 20
ChB.Caption = "Enabled"
Script.RegisterEvent ChB.Common, "OnClick", "ChBClick"
Set Btn = UI.NewButton( Form)
Btn.Common.ControlName = "Btn"
Btn.Common.SetRect 140, 48, 80, 25
Btn.Caption = "Test"
Script.RegisterEvent Btn, "OnClick", "BtnClick"
ChBClick( Form)
Form.ShowModal
Script.UnregisterAllEvents
End Sub
Sub FormResize( Form)
Set FC = Form.Common
Set Lbl = FC.ChildControl("Lbl")
Lbl.Caption = "("&FC.Left&","&FC.Top&")-("&FC.Width&","&FC.Height&")"
End Sub
Sub BtnClick
SDB.MessageBox "Wow, button clicked!", mtInformation, Array(mbOk)
End Sub
Sub ChBClick( ChB)
Set FC = ChB.Common.TopParent.Common
Set Btn = FC.ChildControl("Btn")
Set ChB = FC.ChildControl("ChB")
Btn.Common.Enabled = ChB.Checked
End Sub