Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app #1948

Closed
bairog opened this issue Sep 20, 2019 · 3 comments
Labels
area-HDPI-SA Issues related to high DPI SystemAware mode area-VSDesigner Windows Forms out-of-proc designer related issues

Comments

@bairog
Copy link

bairog commented Sep 20, 2019

  • .NET Core Version: v3.0.0-rc1
  • Have you experienced this same bug with .NET Framework?: No

Problem description:

  1. Using Visual Studio 2019 16.3 Preview 4 create a WinForms .NET Core app and a WinForms
    .NET Framework app, which have same designer code with some controls added.
    WinFormsFrameworkApp.zip
    WinFormsCoreApp.zip

  2. Build and run these 2 apps, and compare size of forms and controls

Actual behavior:
Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app (for example Form is 1178x799 pixels on .NET Core 3.0 and 1010x697 pixels on .NET Framework 4.8)

Expected behavior:
They should have same size (pixel by pixel identical).

@bairog bairog changed the title Size of Form and controls are bigger in WinForms .NET Core app compared to WinForms .NET Framework app Size of Form and controls is bigger in WinForms .NET Core app compared to WinForms .NET Framework app Sep 20, 2019
@bairog
Copy link
Author

bairog commented Sep 20, 2019

In all my form controls I don't use Segoe UI 9pt, I use Calibri 12pt.
Why my forms are not pixel by pixel identical in that case?

@bairog
Copy link
Author

bairog commented Sep 23, 2019

Let me clarify - for example in both projects:

  1. Form size in designer is set to 1028x706 (font is Calibri 12pt)
  2. Button size in designer is set to 70x28 (font is Calibri 12pt)
    .NET Framework 4.8 app respects that sizes, while .NET Core 3 app is bigger than that values..

@RussKie
Copy link
Member

RussKie commented Sep 24, 2019

I believe the result is due to this line:

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

If you comment it out, it renders the form in the same size.

Here's the relevant info: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.containercontrol.autoscaledimensions?redirectedfrom=MSDN&view=netframework-4.8#remarks

@OliaG this may trip a few people, perhaps we need to highlight this somehow.
/cc: @merriemcgaw

@RussKie RussKie closed this as completed Sep 24, 2019
@RussKie RussKie added area-HDPI-SA Issues related to high DPI SystemAware mode area-VSDesigner Windows Forms out-of-proc designer related issues labels Dec 11, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-HDPI-SA Issues related to high DPI SystemAware mode area-VSDesigner Windows Forms out-of-proc designer related issues
Projects
None yet
Development

No branches or pull requests

2 participants