Skip to content

Changing MinimumSize of Form activates the form #7251

@tbambuch

Description

@tbambuch

.NET version

6.0

Did it work in .NET Framework?

No

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

No response

Issue description

In Form.MinimumSize setter, SetWindowPos is called with User32.SWP.NOZORDER flag. I suppose User32.SWP.NOZORDER | User32.SWP.NOACTIVATE should be used, since there is no point in activating the form when MinimumSize changes

The problem I was facing was that MinimumSize and MaximumSize are not scaled when dpi changes (not sure why, in my opinion they should be), so I added scaling of them into OnDpiChanged.
An now the magic happened: changing MinSize activates the form, which looks up the ActiveControl to set focus to. But dpi change arrives too early and the control is not visible yet, so ActiveControl remained null on nonprimary screen, but worked fine on the primary one :/

Steps to reproduce

Metadata

Metadata

Assignees

Labels

area-HDPI-PMv2Issues related to high DPI PerMonitorV2 mode

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions