Hi Sean and Branimir
Thanks, it works now exactly as I wanted it to.
But I'm surprised by the C# environment lacking a high level command to deal
with such a basic issue.
I previously had code in the MainForm_Closing event as I was using e.cancel
to prevent actual close down. I moved this code to the WM_CLOSE intercept,
and didn't pass on the WM_CLOSE back to the system, thus reproducing e.cancel.
I used the WM_QUERYENDSESSION to detect Windows Shutdown to do some final
tidying up.
I come from a VB background which has can detect the following 5 ways that
may be causing an app to close down.
vbFormControlMenu 0 The user chose the Close command from the Control menu
on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session
is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the
application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is
closing.
vbFormOwner 5 A form is closing because its owner is closing.
I see now that I can do all this by intercepting the appropriate messages
but hope that in the next C# upgrade, we will be given the high level
funtions to perform these.
Thanks once again
Tinius