Skip to content

When a Form is opened and StartPosition is CenterParent, it is opened always on the main monitor when the value of WindowState is Maximized regardless of parent's monitor #8932

@carlosmanri

Description

@carlosmanri

.NET version

SDK DE .NET:
Version: 7.0.202
Commit: 6c74320bc3

Entorno de tiempo de ejecución:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.202\

Host:
Version: 7.0.4
Architecture: x64
Commit: 0a396acafe

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No response

Issue description

When a Form is opened and StartPosition is CenterParent, it is opened always on the main monitor when the value of WindowState is Maximized.

If a window is opened on the secondary monitor, instead of being displayed on that monitor it is displayed on the primary.

Because of this, we cannot open maximized forms by default on the same monitor as the parent window.

Here is a test form that demonstrates the observed behavior:

Form1.vb
Form1.Designer.vb

As a workaround, it is possible to set the WindowState in the overridden OnLoad method. (The "Open form that overrides onLoad normal with center parent without parent" and "Open form that overrides onLoad normal with center parent with parent" buttons in Form1). Although if the form contains many controls and takes time to load, you see a rectangle on the wrong monitor before moving to the correct one.

Steps to reproduce

Environment
2 monitor setup (1920x1080 each)
Left monitor assigned as primary monitor

Reproduction Steps:

  1. Run the test application
  2. Move application window to secondary monitor
  3. Click the "Open form normal with center parent" button
  4. Close the modal window
  5. Click the "Open form maximized with center parent" button

Expected result
Both modal windows are displayed on the same monitor as their parent (the secondary monitor)

Actual result
In the case of the form with the value FormWindowState.Normal, it is shown in the parent's monitor.
However, in the form with value FormWindowState.Maximized it is always displayed on the main monitor.

Other observations
It has also been verified that changing the main monitor in the operating system and executing
the steps according to the change (move the application to the secondary monitor before
clicking on the buttons) the behavior is maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 bugProduct bug (most likely)💥 regression-releaseRegression from a public release🚧 work in progressWork that is current in progressarea-HDPI-PMv2Issues related to high DPI PerMonitorV2 mode

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions