As a result, you might notice images and the spacing of the controls are very small in high DPI environments when compared to a 96 DPI environment. WinForms compares the design time AutoScaleDimensions property with the runtime CurrentAutoScaleDimensions and scales the controls accordingly.Įven with these properties, WinForms can still have scaling issues, because the controls use pixels as a form of measurement instead of a device independent unit. This property contains the current run-time dimensions of the screen. If AutoScaleMode is set to Font, it will store the average character size of a font. The value is determined by the AutoScaleMode and is set by the designer. Note: You don’t have to set this property. This property represents the DPI or font setting of the screen that the control was scaled to in the designer. It is recommended to use the default Font setting because it will handle both DPI and system font changes. ![]() If there is no parent, automatic scaling is disabled. This is the default value.Ĭontrols scale according to the classes' parent's scaling mode. Common resolutions are 96 and 120 DPI.Ĭontrols scale relative to the dimensions of the font the controls are using, which is typically the system font. ValueĬontrols scale relative to the display resolution. The scaling is determined by the system font size or the current DPI. This property determines how the controls scale. These properties allow the Formto calculate and scale its child controls depending on the system that designed the GUI and the system that runs the GUI. Luckily, we created a snippet named Set DPIAwareness that will handle the Windows API call for you.Ĭontainer controls such as the Form control, have dedicated properties that govern how the control and its children scale in different DPI environments. You have to call a Windows API, which can be difficult to do in PowerShell.You must change the DPI awareness of a host before displaying a GUI to prevent scaling issues.Changing the awareness of a graphical application that isn’t designed for it can result in rendering and layout issues.This method has some caveats that you should be aware of: Enable DPI awareness using a Windows API call. Use an alternative high DPI host such as a packaged executable.Ģ. This might be a problem for those of you who are not creating their own PowerShell hosts and require a high DPI GUI.ġ. Microsoft’s recommended method of setting a host / application’s DPI awareness is by enabling it the application’s manifest. The following table lists common hosts and specifies if they are DPI aware. If the host is not DPI aware, the GUI will be scaled by the OS, often resulting in a fuzzy presentation. The host running the GUI script must be DPI aware. Requirements for GUI scripts to display in high DPI: The snippets referenced in this article are included in PowerShell Studio 2017 v5.4.139 or above. ![]() You must have PowerShell Studio v4.2.124 or greater installed in order to support GUI scaling within the designer and when executing. Increasing the font scale, will decrease the DPI, which in turn will make icons and text appear larger and easier to see. If you would try to maintain a DPI of 96 on a 4K monitor, everything will appear to be tiny. Higher resolution monitors, such as 4K monitors can have a DPI of 192 or higher (Font scale: >=200%).ĭPI is determined by the font scale of the OS. A typical 1080p screen will a have 96 DPI (Font scale: 100%). To get a better understanding of what different DPI settings mean, let's look at standard screen resolutions. The article will also cover a few caveats to be aware of. Stop talking nonsense and go straight to the subject.ġ.In this article we cover techniques on how to make your PowerShell GUI compatible with high DPI (Dots per inch) displays.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |