To get button onclick events to work, you must useMoDementia 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
Code: Select all
Script.RegisterEvent btnDoIt.Common, "OnClick", "DoIt"
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
If I change to
Code: Select all
SDB.Objects("SimpleAppend") = MainForm
SDB.Objects("SimpleAppend").Common.Visible = True
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.