Issue 775: follow up on possible improper parenting of MessageDlg

Assigned To:Brian Pratt
Opened:2021-03-08 by Brian Pratt
Changed:2021-03-08 by Brian Pratt
2021-03-08 Brian Pratt
Title»follow up on possible improper parenting of MessageDlg
Assigned To»Brian Pratt

referring to pwiz_tools/Skyline/Util/DataGridViewPasteHandler.cs
    MessageDlg.Show(DataGridView, message);

Boy, I am really not sure this is a valid parent. Probably you should get the parent frame of the DataGridView. Some of Nick's windows have an annoying bug where a form that gets show activates the window behind Skyline when it is dismissed. This always boils down to parenting to an invalid parent.

In theory, you should use "FormUtil.FindTopLevelOwner" to find out from a Control what Form you should use to parent a message box.

I don't know what causes the Document Grid window activation bug that Brendan mentioned.

The repro steps for that window activation bug are:
1. View Document Grid
2. Reports > Customize Report
3. Cancel Edit Report dialog
4. Switch to another app and switch back
5. Close document grid
The other app comes to the foreground on top of the main Skyline window.

It seems like any window you might bring up from the Document Grid in step 2 would cause this, such as bringing up the Filter dialog.

This does not happen with other floating dockable windows, such as if you brought up the Properties window on the Peak Area Replicate Comparison

I ought to be able to figure out what the difference is between the way that the peak area window shows the properties dialog, and the way that the
Document Grid shows things, but I have never figured this one out. It seems that I tried to fix this in 2015, and only succeeded in mitigating the problem a little bit by the code that I wrote in FormUtil.ShowDialog.

Anyone else is welcome to try to fix this.

So is this something the AlertDlg base class should do? Check whether parent is a Form, and if it isn't try to use FormUtil.FindTopLevelOwner to find the proper parent?

-- At this point we decided to leave it as is, and create this issue to circle back later.