DeviceScaleChangeEventArgsSuggestedBounds Property
Gets the suggested bounds of the form after scaling.
It may return an empty rectangle if the event is raised before the form is shown, or when the form is an MDI child.
Namespace: KGySoft.WinForms.FormsAssembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
public Rectangle SuggestedBounds { get; }
Public ReadOnly Property SuggestedBounds As Rectangle
Get
public:
property Rectangle SuggestedBounds {
Rectangle get ();
}
member SuggestedBounds : Rectangle with get
Property Value
Rectangle If SuggestedBounds are not applied, and no custom size is set either, Windows may apply the suggested bounds automatically.
If you want to apply custom bounds, make sure that you don't change the screen; otherwise you may end up in an infinite loop
of DPI change due to different scaling of displays. To apply custom bounds safely, make sure you query the
Screen
by the
FromRectangle method using the original
SuggestedBounds, and then
call the
EnsureScreen extension method using the custom bounds and the screen of the original bounds.
SuggestedBounds is empty if the form is an MDI child form. It can be empty also for top-level forms, when a DPI change is detected
during the form creation, out of a DPI change Windows event. This typically happens when the form is shown on a display that has a different scale factor than the primary display.
In such cases there is no DeviceScaleGetNewSize event before the DeviceScaleChanging event,
and there is no DeviceScaleAutoResized event after the DeviceScaleChanged event.
- If your application uses per-monitor DPI awareness V2, you can use the DeviceScaleGetNewSize event to set
a custom desired size in advance, so the SuggestedBounds will be calculated based on that desired size.
- If your application uses per-monitor DPI awareness V1, Windows may forcibly reapply the suggested bounds even if you set a custom size
in the DeviceScaleChanged event. In that case you can use the DeviceScaleAutoResized event to set the custom size safely.