Feature Request: I wish I had the option to open a window with the red close dot disabled, but I could still close the window with a program. The current closeable option for the openform statement prevents closing the window until the database is closed, even with a procedure. The same is true for the nobuttons option. Sometimes I want to force the user to use a close button, which has a procedure to run on closing the form, which can be by-passed if the user used the red dot.
Time for another hack. I made a form called MyForm with one button. I added this code to the button’s Procedure panel:
let TransferForm=exportform("", "MyForm") setformoptions "","MyForm","DELETE","" importform TransferForm
I then opened the form with the close button in the title bar disabled and then clicked the button on the form with the above code. The form was deleted but immediately recreated in the View menu ready for the next use. As you can see, we export the existing form to a variable and then delete the current form and immediately import the same form back again from that variable. Everything looks exactly the same as closing the form normally.
Thanks, Gary. I put your code into a custom statement so I can just replace any closewindow statement with my custom statement.
This closes the window? I’m a bit shocked at that. I would think that a crash would be more likely. I do NOT recommend this technique.
I am assuming that your concern involves the deleting of a form used in an unclosable window and not the importing and exporting of the binary archive of the form. This deletion can also be done manually while the form is open with or without a toolbar.
With the form set to “Closeable”,“no” (note that ‘closeable’ should be spelled ‘closable’) you can click on the “Remove” lightening bolt on the right or go to Graphics Mode and do the same thing and the form and window will be removed. Without a toolbar you can still choose Go to Graphics Mode from the Window menu. Seems that if deleting an unclosable form window is problematic that there are easy ways to fall into this trap by accident.
With a lot of experimenting on this I have not had a crash but maybe I’m just lucky.
My concern is deleting a form while it is open.
However, I have now looked at the source code, and it appears that perhaps this is acceptable. The setformoptions code that deletes a form does check to see if the form is open, and closes the window. So it was actually designed to do this, more or less.
Since the code is more-or-less already written, I should go ahead and make a statement that does this, without the need for the delete/restore trick.
I think the problem here is that the closewindow statement essentially closes the window by sort of “virtually” clicking the close box, and since there is no close box, that doesn’t work.