I have a winforms C# application with multiple MDI child windows, each of which can contain changed user data.
When a child window is closed individually, the user is warned about the changed data, which works fine.
However, if the user attempts to close the application, I only want to warn once for all child windows if any have changed data (the data is not that critical).
So the idea is to hook into the main window's OnClosing event, look for changed user data in any of the child windows, display a warning just once if I find any changed data, and set a boolean to prevent each child window from bothering the user multiple times.
The problem I'm seeing is, the OnClosing event for the main window is triggered AFTER the OnClosing events for each child window are triggered, so I can't set my boolean soon enough.
Is there an event for application closing that I can hook into that arrives sooner than OnClosing, or is there maybe a Windows message I can trap?