6
votes

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!

1
The usual suspect would be Application.ProcessMessages or something else that starts a parallel message loop.Jens Mühlenhoff
If you are not satisfied with native Delphi TRibbon, have a look at Erik van Bilsen's Windows Ribbon Framework.menjaraz
Hi. It may be a lot of work but I suggest instead of doing ShowMessage() or MessageDlg(), Create a new form and show whatever message you want inside that form (you can even do this inside a method/function making it not a lot of work :) ), by doing this you can use the Modalresult function to handle instance specific forms (myForm := TForm1.Create(); if Myform.ShowModal = MrOk then {call second form etc etc ...}) hope this helpsRyno Coetzee

1 Answers

0
votes

This is a known bug. See the report from a 11 years ago http://borland.public.delphi.ide.narkive.com/fVG9CSwl/big-problem-in-delphi-with-modal-forms-please-help I had it too. I had a link to the bug report in embarcadero QA. There is not much you can do.