BaseForm Class
A base form that provides some additional functionality compared to
Form, and contains also some bug fixes.
The
BaseForm class provides the following features and changes:
See also the
example application that contains
multiple examples for
BaseForm features, such as the fixed font scaling, dynamic localization, MDI forms handling, etc.
At the
Releases page of the project repository you can download it as executable binaries as well.
| BaseForm |
Creates a new instance of BaseForm |
| AutoScaleFont |
Gets or sets whether the Font should be automatically scaled when DPI changes and the current thread has per-monitor DPI awareness.
Default value: .
|
| CommandBindings |
Gets the command bindings of this form. Being a WinFormsCommandBindingsCollection,
the Add
methods also add the PropertyCommandStateUpdater to the created bindings.
See the GitHub documentation for details.
|
| DeviceScale |
Gets the current scale of the form's display device. Before loading the form, or when per-monitor DPI awareness is not enabled,
this property returns the system scale of the primary display, which is the same as the ScaleHelper.SystemScale property.
|
| DynamicStringLocalization |
Gets or sets the dynamic string localization strategy of the form. It allows using potentially auto-generated string resources from .resx files.
|
| Font | Gets or sets the font of the text displayed by the control. (Overrides ControlFont) |
| Icon | Gets or sets the icon for the form. |
| IsDesignMode |
Gets whether the form is in design mode. Unlike the DesignMode property,
this property works even during initialization.
|
| IsLoaded |
Gets whether the form has already been loaded. This property is after the Load event is raised for the first time,
and remains even if the form is shown as a dialog multiple times or the handle is recreated (e.g. because RightToLeft changes).
Can be useful if you override the OnLoad method, and you want to avoid executing some initialization more than once.
|
| IsSuspended |
Gets whether the form is suspended by an owned MDI child.
|
| MdiClient |
Gets the corresponding MDI client of the form, or , if this form is neither an MDI container nor an MDI child.
|
| OwnedMdiChildren |
Gets the forms that were shown as MDI children by the ShowMdiChild method.
|
| SuspendingMdiChild |
Gets the MDI child that is suspending this form by a ShowMdiChild call,
or if this form is not suspended. When this property is not ,
the returned form is among the elements of the OwnedMdiChildren property.
|
| ToolTip |
Gets a ToolTip instance that can be used to show tooltips for controls of this form.
|
| TranslateControls |
Gets or sets whether the form should translate its controls.
This property is obsolete. Use the DynamicStringLocalization property
or override the ApplyResources and/or ApplyStringResources methods.
Obsolete |
| ApplyResources |
Applies the resources of the form. The default implementation just calls the ApplyStringResources method.
Called when the form is loaded for the first time. In a derived form, this method can be overridden to apply additional (non-string) resources,
and it can be called whenever the form's resources should be re-applied, e.g. when the display language changes.
|
| ApplyStringResources |
Applies the string resources of the form. If the DynamicStringLocalization property is not set to Disabled,
the default implementation just calls the LocalizationHelper.ApplyStringResources method.
In a derived form, this method can be overridden to apply a custom string localization, and it can be called whenever the form's string resources
should be re-applied, e.g. when the display language changes.
See the Remarks section of the DynamicStringLocalization property for more details.
|
| Dispose |
Disposes the form and its resources.
(Overrides FormDispose(Boolean)) |
| GetScaledBounds | Retrieves the bounds within which the control is scaled. (Overrides FormGetScaledBounds(Rectangle, SizeF, BoundsSpecified)) |
| InvalidateMdiClientArea |
Invalidates the MDI client area. Has effect only if the IsMdiContainer or IsMdiChild is for this form.
|
| InvokeOnUIThread |
Invokes the specified callback on the thread that the control was created on.
|
| OnCalledMdiChildClosed |
Raises the CalledMdiChildClosed event.
This method is obsolete along with the CalledMdiChildClosed event.
Use the OwnedMdiChildClosed event and the OnOwnedMdiChildClosed method instead.
Obsolete |
| OnDeviceScaleAutoResized |
Raises the DeviceScaleAutoResized event.
See the Remarks section of the DeviceScaleAutoResized event for more details.
|
| OnDeviceScaleChanged |
Raises the DeviceScaleChanged event.
See the Remarks section of the DeviceScaleChanged event for more details.
|
| OnDeviceScaleChanging |
Raises the DeviceScaleChanging event.
See the Remarks section of the DeviceScaleChanging event for more details.
|
| OnDeviceScaleGetNewSize |
Raises the DeviceScaleGetNewSize event.
See the Remarks section of the DeviceScaleGetNewSize event for more details.
|
| OnDynamicStringLocalizationChanged |
Raises the DynamicStringLocalizationChanged event.
|
| OnFontChanged | Raises the FontChanged event. (Overrides FormOnFontChanged(EventArgs)) |
| OnHandleCreated | Raises the HandleCreated event. (Overrides FormOnHandleCreated(EventArgs)) |
| OnLoad | Raises the Load event. (Overrides FormOnLoad(EventArgs)) |
| OnOwnedMdiChildClosed |
Raises the OwnedMdiChildClosed event.
|
| OnParentChanged | Raises the ParentChanged event. (Overrides ContainerControlOnParentChanged(EventArgs)) |
| OnParentFontChanged | Raises the FontChanged event when the Font property value of the control's container changes. (Overrides ControlOnParentFontChanged(EventArgs)) |
| OnResumed |
Raises the Resumed event.
|
| OnSuspended |
Raises the Suspended event.
|
| PerformTranslate |
Translates the controls and tooltips of the given control.
Obsolete |
| ShowMdiChild |
Shows the form as an MDI child, owned by of this BaseForm.
This BaseForm must be either an MDI container or another MDI child.
|
| WndProc | Processes Windows messages. (Overrides FormWndProc(Message)) |
| CalledMdiChildClosed |
Occurs when an MDI child shown by a ShowMdiChild method call is closed.
Obsolete |
| DeviceScaleAutoResized |
Occurs with per-monitor DPI awareness, when the form is resized automatically after the DeviceScaleChanged event.
|
| DeviceScaleChanged |
Occurs with per-monitor DPI awareness, when the scale of the form's display device changes, after performing the default processing of the corresponding Windows message.
On platform targets where the DpiChanged event exists, this event is raised after DpiChanged.
|
| DeviceScaleChanging |
Occurs with per-monitor DPI awareness, when the scale of the form's display device changes, before performing the default processing of the corresponding Windows message.
On platform targets where the DpiChanged event exists, this event is raised before DpiChanged.
|
| DeviceScaleGetNewSize |
Occurs with per-monitor DPI awareness V2, before calculating the suggested bounds for the DeviceScaleChanging and DeviceScaleChanged events.
Similar to the Form.OnGetDpiScaledSize method, but this is available also as an event for all .NET versions, and it does not cache the result.
|
| DynamicStringLocalizationChanged |
Occurs when the DynamicStringLocalization property has changed.
|
| OwnedMdiChildClosed |
Occurs when an MDI child shown by the ShowMdiChild method is closed.
|
| PaintMdiClientArea |
Occurs when MDI area of the form has to be repainted. IsMdiContainer must be true to access this event.
Obsolete |
| Resumed |
Occurs when the MDI Child window called by ShowMdiChild that suspended the caller instance is closed.
|
| Suspended |
Occurs when an MDI Child window called by ShowMdiChild suspends the caller instance.
|