Board index » delphi » MDI Child doesn't close when ApplicationMenu Close() is clicked

MDI Child doesn't close when ApplicationMenu Close() is clicked

In the MDI child the CanCloseQuery event has a test to see if the data has
changed and when it has changed, the user is given a choice to save first, close
anyway and cancel.

A problem occurs when the option Close Anyway is chosen, even though the
CanClose variable is set to true. There are 3 situations in which this query is
called and 2 work and 1 doesn't.

If the MDI child is closed by clicking on the top-left close button on the
window header then the child window closes correctly.

If the main form's Exit button (or menu item) the code attempts to close all
child forms. In this case the forms correctly close if the user elects to close
anyway in the case of changed data.

Problem: If the main form's close button (top-right on the header) or the
application icon (top-left of header) is double-clicked or Alt-F4 is pressed
then the MDI child does not close when the option to close anyway is selected.

What could be causing this anomolous behaviour?

How can I fix it?

Is there a way to capture the application's Close action so that I have control
over its default behaviour? This default behaviour appears to include issuing a
close command to the MDI children.

Raymond Kennington

 

Re:MDI Child doesn't close when ApplicationMenu Close() is clicked


In the MDI child the CanCloseQuery event has a test to see if the data has
changed and when it has changed, the user is given a choice to save first, close
anyway and cancel.

A problem occurs when the option Close Anyway is chosen, even though the
CanClose variable is set to true. There are 3 situations in which this query is
called and 2 work and 1 doesn't.

If the MDI child is closed by clicking on the top-left close button on the
window header then the child window closes correctly.

If the main form's Exit button (or menu item) the code attempts to close all
child forms. In this case the forms correctly close if the user elects to close
anyway in the case of changed data.

Problem: If the main form's close button (top-right on the header) or the
application icon (top-left of header) is double-clicked or Alt-F4 is pressed
then the MDI child does not close when the option to close anyway is selected.

What could be causing this anomalous behaviour?

How can I fix it?

Is there a way to capture the application's Close action so that I have control
over its default behaviour? This default behaviour appears to include issuing a
close command to the MDI children.

Raymond Kennington

Other Threads