MoDementia wrote:This only works if you use OnClickFunc for buttons Onclick Events produce errors
as there is no OnClickFunc for OnClose Form using the "X" produces errors
Back to Jiri
To get button onclick events to work, you must use
Code: Select all
Script.RegisterEvent btnDoIt.Common, "OnClick", "DoIt"
Now I have another problem which I suspect has something to do with showmodal:
I am creating a form with some controls on it, with an OK and (hidden) cancel button.
When I click escape, the cancel event fires but does not close the form. When I use the X on the dialog to close, it fires the cancel event and closes the form.
pseudocode
Code: Select all
Sub Start()
Set MainForm = SDB.UI.NewForm
Script.RegisterEvent MainForm, "OnClose", "CloseMe"
Dim btnClose
Set btnClose = SDB.UI.NewButton(MainForm)
btnClose.Cancel = True
btnClose.Common.SetRect 0,0,0,0
Script.RegisterEvent btnClose.Common, "OnClick", "CloseMe"
MainForm.ShowModal
SDB.Objects("SimpleAppend") = MainForm
End Sub
Sub CloseMe(obj)
msgbox("Closing")
Script.UnregisterAllEvents
Set SDB.Objects("SimpleAppend") = Nothing
End Sub
Escape/cancel does fire the event, but the form remains visible.
If I change to
Code: Select all
SDB.Objects("SimpleAppend") = MainForm
SDB.Objects("SimpleAppend").Common.Visible = True
Then the form disappears with escape/cancel.
Is there a problem with form.showmodal or am I not doing something I should be?
edit:
I think I figured it out after studying bex's example more. But apparently you can not close a modal dialog by setting the object to nothing like you can with a normal form.
[quote="MoDementia"]This only works if you use OnClickFunc for buttons Onclick Events produce errors
as there is no OnClickFunc for OnClose Form using the "X" produces errors :(
Back to Jiri :( :x :cry:[/quote]
To get button onclick events to work, you must use
[code] Script.RegisterEvent btnDoIt.Common, "OnClick", "DoIt"[/code]
Now I have another problem which I suspect has something to do with showmodal:
I am creating a form with some controls on it, with an OK and (hidden) cancel button.
When I click escape, the cancel event fires but does not close the form. When I use the X on the dialog to close, it fires the cancel event and closes the form.
pseudocode
[code]
Sub Start()
Set MainForm = SDB.UI.NewForm
Script.RegisterEvent MainForm, "OnClose", "CloseMe"
Dim btnClose
Set btnClose = SDB.UI.NewButton(MainForm)
btnClose.Cancel = True
btnClose.Common.SetRect 0,0,0,0
Script.RegisterEvent btnClose.Common, "OnClick", "CloseMe"
MainForm.ShowModal
SDB.Objects("SimpleAppend") = MainForm
End Sub
Sub CloseMe(obj)
msgbox("Closing")
Script.UnregisterAllEvents
Set SDB.Objects("SimpleAppend") = Nothing
End Sub
[/code]
Escape/cancel does fire the event, but the form remains visible.
If I change to
[code]
SDB.Objects("SimpleAppend") = MainForm
SDB.Objects("SimpleAppend").Common.Visible = True
[/code]
Then the form disappears with escape/cancel.
Is there a problem with form.showmodal or am I not doing something I should be?
edit:
I think I figured it out after studying bex's example more. But apparently you can not close a modal dialog by setting the object to nothing like you can with a normal form.