"Iain" <id********@dircon.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I would like to prevent the user from closing MDI child windows. However,
I would like them to be able to minimize and maximize them.
Setting the Control Box to false removes the minimize and maximize too.
An obvious thing to do is to handling the CLosing event and cancel it.
Sadly, if you do this the main Form refuses to shut down...
A solution to this is to intercept the Closing event on the main form and
use it to set a boolean that the children can check to see if they CAN
close down.
But this is raised *after* the childrens events.
As a user I would be offended by you inhibiting me from closing the MDI
child. If you don't want me to close a child, the close option should be
disabled. It would be wrong to offer the close option, accept the command
and than fail to comply.
MDI has practically been deprecated for some time now, Microsoft does not
encourage to use it.
In an MDI application, all MDI Windows should contain documents of the same
type. If you are presenting different types in different MDI windows, MDI
does not apply and it should not be used.
If you are showing singleton documents/objects of different types in MDI
child windows and you were to ignore my valuable advise to not abuse the MDI
model, you could make the result less annoying on the user by accepting the
close command and hiding the child instead of closing it. The MDI window's
View menu could them offer a list of views that can be checkmarked in order
to make them visible or hide them. Close on a child would be the shortcut
for going into the menu and hiding it.
Martin.