Open hmisaki opened 1 year ago
Maybe related to #9200?
@dreddy-work this seems like your area.
@elachlan, I see this is reported against .NET 6.0. @Olina-Zhang, can you help validate this against latest bits in main and add a repro app?
Maybe related to #9200?
It seems not the same issue. After more research, there is more information: it seems to be caused by the GroupBox and the AutoSize option on the checkbox. The checkbox seems to be scaled twice. If I add the background color to the checkbox, we will get the size of the CheckBox: we guess that the checkbox is scaled twice, once by DPI, and the other one by Font.
@dreddy-work verified this issue in the latest bits from Winforms repo based on 8.0 SDK build, this issue can reproduce, it has the same result as .Net 6.0. It just reproduces when Form's AutoScaleMode is Dpi, doesn't reproduce with setting Form's AutoScaleMode to Font. The sample app: WinFormsApp14.zip
https://github.com/dotnet/winforms/assets/26474449/429a2803-6770-4c53-9092-c2c37610e54a
@dreddy-work verified this issue in the latest bits from Winforms repo based on 8.0 SDK build, this issue can reproduce, it has the same result as .Net 6.0. It just reproduces when Form's AutoScaleMode is Dpi, doesn't reproduce with setting Form's AutoScaleMode to Font. The sample app: WinFormsApp14.zip
Issue9293.mp4
Regarding this being a dotNet bug, we have some dialog layout issues that appear to be related to this problem. Could you please provide an update on the current situation? We are curious to know if there is a schedule in place to address this issue and if the fix is intended to be included in the upcoming .NET 8 Release. We would greatly appreciate your kind response.
@hmisaki, Our objective is to enhance the overall user experience in .NET Core when utilized with high DPI devices. This is particularly relevant for SystemAware (default mode) applications, and it aligns with the priority of our ongoing work in WinForms. Regarding the release schedule, I will provide an update once we complete the initial investigation and have a clear understanding of the extent of the required fix.
@dreddy-work assigning to you and removing untriaged label. I set it to .NET 8 but will defer to your judgement on when it can go into the product after your investigation.
I read your comments regarding the effect of check boxes inside group boxes and would like to report that other controls, such as combo boxes and text boxes are also getting "chopped off" because the group boxes are not resized properly. This is not just happening in other computers with monitors with different resolutions from the development machine resolution. It is also happening in the development computer itself, that is, what I see in the form designer is not what I get when the form is displayed at runtime.
My development machine settings:
LG Monitor, 3840 x 2160, Scale: 100% Visual Studio 2022, .Net 7, C# 11
static void Main() { ApplicationConfiguration.Initialize(); // I have left in or commented out the SetHighDpiMode statement but made no difference Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); Application.Run(new DocumentMateDialog()); }
private void InitializeComponent() { // I have left in or commented out the following two statements is various combinations to see if any would // solve the problem but it did not this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
// The AutoScaleMode actually made it worse because the group boxes chopped off the combo boxes the same as during // runtime this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; FormDesigner.txt
... }
[2023-07-22] At design time the GroupBoxes are set to a height of 50 pixels and the ComboBoxes at a height of 23 pixels. At runtime the GroupBoxes remain at a height of 50 pixels but the ComboBoxes have been resized to a height of 29 pixels. It seems that the GroupBoxes are not being resized but their contents are. This is why it is chopping the controls at the bottom.
@Olina-Zhang , can you also capture results for the sample DocumentDriller
mentioned above, for both DPI and Font modes? designer.cs
file for this dialog is attached above.
@dreddy-work verified the sample DocumentDriller in .NET 8.0 latest build 8.0.100-rc.1.23401.24, for both DPI and Font modes on 100% & 300% DPI, at run time, the ComboBox display well as it was in design time. Following is the repro video: Test app: WinFormsApp57.zip
Thank you very much, guys. This is great news. I am looking forward to running my applications in .NET 8 in October. Keep up the great work. Take care.
@MarcoAuday, just an FYI, we still have issue for AutoScaleMode = DPI
and we are looking into it in the next release. Font
is our default AutoscaleMode
.
@dreddy-work does this still need to remain open for tracking?
Hello, I've noticed that the milestone has been updated to .NET 9.0. Does this mean that we won't receive a fix for this issue in the official .NET 8 release? We've been encountering layout problems in a set of dialogs due to this bug. If we won't be getting a fix in the .NET 8 release, is there a workaround available? Setting AutoScaleMode to Font seems to be unfeasible in our project.
Hi Devendar, Hi Olina,
I have created a test application with a form that contains several different types of controls, docked and undocked, and hosted by Panels and GroupBoxes. You will notice that the controls are kept very tight inside of their hosts in order for you to catch any mis-alignment that may come up during the High DPI tests.
You will also be able to control the font size of the controls on-the-fly by selecting it from the Font combo box at the top of the form.
If you need more test cases, or any test scenario in particular, please let me know.
Thank you for trying to solve this problem.
Take care. WinFormsHighDPITest.zip
Still a problem with .NET 8/9.
We have a very large amount of dialogs in our application which are all affected by this misbehavior when displayed on monitors with 150% DPI scaling or more.
.NET version
.Net 6
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No
Issue description
The WinForm dialog display incorrectly in the high DPI(>100%) see the screenshot: This is the correct display: But if I add a
Font = Font
orScale(new SizeF(1.0F,1.0F))
to the end ofInitializeComponent
, we can get the right display again:So why do I need the extra code to make it display correctly? We just migrated our code to .net 6 from .net 4.8. There are no these situations on the .net framework 4.8. Did we have any solution to handle this on the high DPI?
Steps to reproduce
Create a new WinForm project (.net 6) Use a groupbox, and fill in some checkboxes. Set the dialog's AutoScaleMode to Dpi. Building. Set the system Scale to 200% (system settings ->Display -> Scale and layout). Open the new exe.