question

SunnySharma-5128 avatar image
0 Votes"
SunnySharma-5128 asked JialeXueMSFT-4441 commented

We are building a Winform app on DotNetcore 6 but the app is not adjusting to different screen resolutions

We are building a Winform app on DotNetcore 6 that need to work on laptops but the app is not adjusting to different screen resolutions even though we have utilized anchor and dock properties of the winform controls. Since the app works fine on resolution 1333*768 with 100% scaling and layout (image attached) 254184-resolution.jpg. I am wondering whether that's possible to start the app in custom resolution all the time by writing c# program irrespective of the host system resolution? Is this something that is achievable


dotnet-csharpdotnet-standarddotnet-clidotnet-adonet
resolution.jpg (23.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JialeXueMSFT-4441 avatar image
0 Votes"
JialeXueMSFT-4441 answered JialeXueMSFT-4441 commented

Hi @SunnySharma-5128, Welcome to Microsoft Q&A.

There are 3 kinds of applications:

  1. Not DPI aware

  2. System DPI aware

  3. Per monitor DPI aware

Related Document: https://learn.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows?redirectedfrom=MSDN#dpi-awareness-mode

You can set the DPI-awareness on your application in app.config:

 <appSettings>
     <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
 </appSettings>

and app.manifest:

 <application xmlns="urn:schemas-microsoft-com:asm.v3">
   <windowsSettings>
     <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
   </windowsSettings>
 </application>

Best Regards,
Jiale


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

We tried above but unfortunately it still is not working as some of the controls are getting overlapped when setting to higher resolution and where the scaling is set at 125 and 150%. Since the app works fine in resolution i.e 1366*768 with 100% scaling, Isn't there a way to always open the app in this specific resolution irrespective of the host machine resolution?

0 Votes 0 ·

It is recommended that you add <ApplicationHighDpiMode>DpiUnaware</ApplicationHighDpiMode> to the propertygroup

If it still doesn't work, it is recommended to manually add the resolution adaptive code.

By the way if you have custom controls in your app, you may need to set their size manually.


0 Votes 0 ·