Hi,
I don't use
MDI much (only in past projects or not mine), so my knowledge is very little, as for you example, few inline var and the compiler complained about the part marked with "// Covered Window" so i commented that part and it did compile and ran fine on XE8 without problem, yet the observed behavior is correct not like your test11.
Anyway, i do recognize the pattern of this discrepancy from different places like tabs in pages, and i think the problem is Z-Order handling and has little to do with
VCL itself, in fact i think the more you try to fix it the more corrupt and unpredictable it will become, so you have to put your own mechanism to manage Z-Order for windows, created then closed, in other words you have to manage the focus on close manually.
Things to watch for as example, browsers behave different when you form one page open lets say three tabs then switch to the middle one then close it, which one will be the main now, Chrome and FireFox behaved differently over many versions and updates.
Anyway, i want you to read
https://learn.microsoft.com/en-us/wi...atures#z-order and specially give extra attention to this phrase "for windows of the
same type", i for myself not sure i do understand what "same type" means, because it meant different things in different places, in other words i don't think it means what you expect.
Mixing
MDI with non-
MDI will shuffle Z-Order and make things harder to track, some will return focus to its parent, some will return to its "same type"!!
Hope that help somehow.