I am currently developing an MDI application.
Every time a new MDI child window is created, it's underlying data is saved on the fly to an SQLite database and the column open
is set to 1
, so if the user closes the program and reopens it, the windows are restored (also in case of Anything BadTM).
So every document is always present in the database - the only thing that happens if the user clicks "Save" is that the column persistent
is set to 1
.
Now if an MDI child window is closed, open
is set to 0
- and every row with persistent=0 AND open=0
is doomed and will be deleted.
As a result of this behaviour I don't need to ask "Save documents?" on ApplicationClose.
But I do need to ask every time an MDI child window is closed.
That would all be easy to do if Mainform.OnCloseQuery
would be called before MDIChild.OnCloseQuery
, but sadly that's not the case.
To sum it up:
I need a way to know whether MDIChild.OnCloseQuery
is called because
- the application is shutting down, or
- the MDI child window is being closed.
Is there any way to do this?
true
on app shutdown would be great. That is what I meant with "it would be easy ifMainform.OnCloseQuery
would be called first". – Pharaoh