I am developing Windows form application using C#. I found that this application is scaled correctly if I used the default scaling offered by Windows 10 (100%, 125%, 150%). But if I used the custom scaling like 110%, 115%, 135%,... the application gone bad. You can see the picture bellow (left is 125% and right is 135%).
What I have tried so far: enabled dpi awareness, set AutoResizeMode to none/dpi/font, but didn't work.
Is there anyway I can prevent the Windows from breaking my application if the custom scaling is enabled? I know the Winform is old and also maybe its the Windows problem itself, but any advices will be appreciated.
Related
I have a C# desktop application which is developed in dot net framework 4.6.2. This application is working finr in Win 10. But when same application is run in Win 11, all form controls are disturbed. Like few buttons are totally hidden. Is there any global fix? I don't want to reposition and resize the forms and controlls again for the whole application.
The issue you have is because the Windows 11 computer has a different screen DPI setting. Winforms is notoriously bad at scaling with any setting other than 100%. If you cannot run 100% all the time, then you will have to do some coding magic to detect DPI setting and adjust margins and padding... Or you could redo your UI in WPF, which scales properly at any setting.
Some possible avenues to explore if you rebuild to .NET 4.7+:
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8
We have an issue on our windows store app, it uses a WebView to display custom generated html from the filesystem. The app is written in WPF / Xaml and so the native UI components scale automatically depending on what the user has set their screen scaling to - however the embedded WebView does not - meaning on my laptop's 4k screen, the WebView font is incredibly tiny. At the moment we have to support windows 8.1 so we are compiling for that target - which means we are embedding a IE11 instance. I thought setting the browser zoom level may be a short term solution but it ends up with horizontal scroll bars on the main window so that's a no go.
I found a MSDN article which shows there is a problem with the underlying COM component not automatically being notified of the high DPI awareness of the app it's being embedded within. The article shows how to get around the issue by overriding what flags the component is sent. However upon going down that route, it seems the WebView that is available on the UWP platform is abstracted even further and you cant grab the instance of the Document MSHTML object needed for the above fix to work.
I also noticed this answer which seems to infer there's a scale factor conflict between windows 8.1 apps and the windows 10 OS, but I am unable to locate any more information on that particular issue.
Any advice would be most welcome as I can't imagine what we're doing is that rare.
Thanks
Turns out this is caused by a combination of factors:
We are using Bootstrap 3, which sets the root HTML font size to 10px, and as IE WebView (Even Edge) uses font size adjustments to deal with DPI scaling, having a base font size set disables this functionality.
Windows Apps which target Windows 8.1 have a maximum scaling of 200% (as that was the maximum supported at the time). However Windows 10 increased this limit to iirc 400%. My laptop screen is set to 250% as it's 4k but when I put a windows 8.1 app onto it, the maximum they go to is 200% so there is a slight size reduction there as well.
I still think this is a fairly serious issue in the Windows Store WebView control as if I open up the bootstrap site in standard edge, it is fine. Even if I do the same with IE11, the page content looks OK even if IE11 itself does not handle DPI at all.
I'm trying to program a security System using a Raspberry Pi and new Windows Universal App Platform (so I'm using Windows IoT).
This security System should look like the LCARS OS, used in the "younger" Star Trek Spaceships. I had no Problem designing the Buttons etc. but if you know LCARS, you know that there are theese so called "elbows". I thought it would be a good idea to use a canvas for that.
I tried to give the canvas a border that is drawn with a beziercurve but that did not work.
Actually I have no idea how I could resolve the problem. Is there anybody who may help (or has a complete different /better idea)?
I'm using C# with XAML for developing (Blank Windows Universal App Template).
I'm developing a small winforms app for internal use. My dev pc runs Windows 7 however most of the other team members (i.e. the users of the app) are running Windows 8.1. The winforms controls all render slightly differently in Windows 8.1 and this causes some problems such as buttons cutting off text due to size differences.
Is there a way to see how the app will render in Windows 8.1 on my Windows 7 dev PC? Note I'm talking about a regular winforms app, not a Metro style app.
I'm developing in C# using Visual Studio Professional 2013
EDIT
Note that I have now also tried using https://github.com/viperneo/winforms-modernui and I get similar behaviour. I have a DateTimePicker next to a Button and I make their height's the same. On my Windows 7 dev PC this looks correct. However when I run it on a Windows 8 "production" PC the button height is now shorter than the DateTimePicker, things become misaligned in general and some controls even start to partially overlap. The screen resolutions of the two PCs is the same
Check to see what DPI setting that all/each of your users are using. Windows Forms will always render differently with each DPI scaling setting regardless if it is Windows 7 or Windows 8. Takes a fair bit of work in dev and testing with each major DPI increment but it can be done to get a decent look.
i am working on visual studio 2010.
i created my master form windows state is Maximized
my system resolution is 1366X768 ,,in one button click i am calling 5 forms together into my master form.. but in my system everything getting correct..
but i installed the same application in my client system,,that system resolution is 1024X768
but here my alignment is not getting proper..now my image is getting like this:
so how i can fit my windows form application in all resolution,,if any one know please help me to find out
You basically have two options:
1) Follow Microsoft's instruction on implementing auotscaling for Windows forms applications. (See http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx)
2) Write your own code to scale the form based on resolution.
============================
Other factors to keep in mind.
If you app is translatable that can affect scaling
A user changing the Windows default font size can have the same affect.
Hope this helps.