Windows.Forms.Form opening outside of visible desktop/screen area
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
### Description
If you have multiple screens, a Form may be opened outside of visible screen area if you open a new form with StartPosition = WindowsDefaultLocation using code like this:
anotherForm another = new anotherForm();
another.Owner = this;
another.ShowDialog();
If you use
another.ShowDialog(this)
the form will however open next to your original form.
In my case I have 3 screens, from left to right:
1. 3840x2160 at 150%,
2. 2560x1600 at 150%
3. 1920x1080 at 100%
### Reproduction Steps
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
anotherForm another = new anotherForm();
another.Owner = this;
another.ShowDialog();
}
}
----
### Expected behavior
Expected the Form to be somewhere within the visible screen area.
### Actual behavior
Form is shown in Taskbar, but is outside visible area.
It is possible to move the Form back into visible area e.g by selecting it in task bar and using Win+Left.
### Regression?
_No response_
### Known Workarounds
Set (Form).StartPosition = other value than WindowsDefaultLocation,
or use (Form).ShowDialog(this).
### Configuration
Windows Forms app (.NET Framework) v 4.8.
C# and VB tested, x86 debug/release and any cpu tested.
Windows 11 Pro 10.0.22621 Build 22621
Not tested on other configurations.
### Other information
Probably something to do with calculation of startup position based on the dpi of the screen the Form currently is on.
Contributor guide
Assessment
This issue has not been assessed yet.