In my WinForms C# app, I need to find the MDI child window that is the least-recently-used, i.e. the window that was last used the longest time ago.
This is in order to close it to make room for a new window.
My theory is that the z-order (e.g. controlled by SendToBack and BringToFront) would indicate the least-recently-used window, as any action performed on a child brings that window to the front of the z-order, so consequently the back of the z-order could be used to indicate the least-used (correct me if I'm wrong).
If I iterate through the MDIChildren on my panel, they are always returned in creation order, which is close, but not quite what I want.
Really all I effectively need is the opposite of a SendToBack function. Or is it possible to get access to the z-order itself?
I could of course reinvent the wheel and implement my own container that keeps track of the least-recently-used child, but getting at the z-order would be easier!