Here is my problem.
I have the main app running and open a modal dialog1, at this point the main app screen is disabled and all focus in on the new dialog1.
From this dialog1 I open another modal dialog2. So now the main screen and the dialog1 are disabled and this dialog2 has all the focus. Perfect so far.
Now when I close this top dialog2, I would expect it just to jump back to dialog1. It focuses on dialog1 but it the main app is now enabled and you can click anywhere which sends the dialog1 behind but leaves it open. This causes problems for the 1% of times that a user doesn't just close dialog1 down immediately and goes clicking around. As you can imagine QA doesn't like this ;o)
It looks like Windows is getting a bit confused because the main app seems to know it's still got the dialog1 open as the button on the ribbon is still down.
Any ideas?
The best I have managed so far is to set explicitly:
dialog1.PopupMode := pmExplicit;
dialog1.PopupParent := MainFrm;
This seems to keep dialog1 ontop of the main app when you close dialog2 even if you click on the main app. So that will encourage the user to close it down but isn't 100% correct.
Edit: I have since created a standalone app and it functions as expected. As you close the windows, control and focus goes back from dialog2 to dialog1 then to then main app when dialog1 is close. The suggests something else is going in our ribbon code that I can't find. Humph!
Application.ProcessMessages
or something else that starts a parallel message loop. – Jens Mühlenhoff