Center dialogs and message boxes on their parent window - #106
Florian Hopfner (FH-Inway) merged 1 commit into
Conversation
Dialogs and message boxes were shown without an explicit owner, so FormStartPosition.CenterParent had no parent to center against and placement fell back to inconsistent, sometimes off-monitor behavior (especially for non-modal Form.Show(), which never infers an owner). Passing the parent form explicitly to ShowDialog/Show/MessageBox.Show throughout MainForm, RDPConnect, AssetLibrarySearch, AddNSG, Parameters, and ChooseProject makes every dialog center on and stay stacked above its parent, on the parent's monitor.
d05068f to
00825b1
Compare
|
@microsoft-github-policy-service agree |
|
Tomas Hansson (@tomashan) Thanks for reporting and the pr. I will take a closer look after I'm back from vacation. |
|
Florian Hopfner (@FH-Inway) Thanks, no rush - enjoy the rest of your vacation! Good question, but it's not multi-monitor specific - I can reproduce it on a single monitor too. A screenshot doesn't really capture the bug well, since the issue is that the dialog's position has no relationship to the parent's position at all. Here's a diagram instead:
Left panel (before the fix): the same main window is shown in two positions (1 and 2). In both cases Right panel (after the fix): with Happy to put together real screenshots too once you're back if that's still useful, but I think this shows the root cause more clearly than a screen capture would. |
|
Thanks for the diagram, that was helpful. I tried various ways to reproduce the issue, but was not quite successful. It seems that the issue may only occur with dialogs that are generated during runtime, but have no explicit form defined? Best result was when I tried the "RDP and passwords > Show passwords" dialog from a cloud hosted instance context menu (right click). There before the pr changes, when having the main window on a monitor different from the main monitor, the dialog is shown near the top left corner of the main monitor. With the pr changes, it shows the dialog on the same monitor as the main form, but still near the top left corner, not centered on the main form. In any case, the pr changes are looking good, so I went ahead and merged them. This is now available in version 0.54.0. Thanks for the fixes. In case you want to follow up, I also noticed that the |

Summary
Dialogs and message boxes were shown without an explicit owner, so
FormStartPosition.CenterParenthad no parent to center against and placement fell back to inconsistent, sometimes off-monitor behavior (especially for non-modalForm.Show(), which never infers an owner).This change passes the parent form explicitly to
ShowDialog/Show/MessageBox.ShowthroughoutMainForm,RDPConnect,AssetLibrarySearch,AddNSG,Parameters, andChooseProject, so every dialog centers on and stays stacked above its parent, on the parent's monitor.Test plan
msbuild 2LCS.sln) — succeeds with no warnings/errors