I recently updated my development workstation to Windows 8.1 with a 4K monitor and went from Visual Studio 2010 to 2012. When I opened an existing project sweeping changes were made to Margin and Padding (were default).
Label - Margin(8, 0, 8, 0)
Button, DataGridView, TextBox, CheckBox - Margin(8, 7, 8, 7)
MenuStrip - Padding(16, 5, 0, 5)
GroupBox - Margin(8, 7, 8, 7) and Padding(8, 7, 8, 7)
The control Sizes are also bigger than before.
Is this because I'm using a 4K monitor with display scaling? If so, how can I control layout with this setup. Do I have to change my display resolution every time I want to edit the form?
Or is it something to do with VS 2012 or Win 8.1?
Any help is appreciated.
The answer relates to DPI scaling. Basically, when something is edited in the designer other than at 96 DPI, it is scaled. When you save, the scaled values are saved. I was editing a form at 150 DPI.
I find the DPI support in Winforms to be pretty awkward but the wisdom seems to be to use the designer at a consistent DPI - i.e. on the same monitor and preferably at 96 DPI.
I have certainly found that it is difficult to get layout correct at higher DPI. I just can't see if things are properly aligned at higher DPI whereas I can see it clearly at 96 DPI. So, whether the advice to stick to 96 DPI is technically required or not I can't confirm but as a practice I find it visually necessary.
Here are some answers about how to build DPI Aware applications: https://stackoverflow.com/a/13228495/1439940, https://stackoverflow.com/a/4076259/1439940, https://stackoverflow.com/a/202172/1439940
Related
I create my programs on Ubuntu 12.04 and compile them on Windows (when necessary).
Recently I noticed that my Lazarus projects look different on Ubuntu and Windows. The problem is on Windows XP, 7 and 8. I'm not sure if Vista looks the same.
For example, group boxes containing radio buttons look shrunk in height, thus hiding parts of the components.
Now I have to edit this forms on Windows before compiling for those platforms. What's worse is that when I bring these project back to Ubuntu, the forms looks unnecessarily stretched out (in height).
Is there a solution to this?
Thanks!
It is easily to check if the controls themselves have the same height(just query their left and top properties and dump it in a memo or log for verification)
If that is ok, it is probably the font. Default fonts are subject to themes, and sometimes readability/disability settings.
Consistent cross-platform look is not a trivial task and does not come at no-cost.
Read http://wiki.freepascal.org/Autosize_/_Layout, especially the part that can scale controls on your form depending on the font size that the end user has configured in the Control Panels
Read few chapters from Google: "windows dpi aware applications"
We are having a problem with one of our existing Win32 MFC based applications. It does not render correctly on displays that use high dpi settings. More specifically in Windows XP with 120 dpi selected, there are several places in the app where the text scales up but not their containers (text overflowing the bounds of it's button, etc). This also occurs in Windows 7 (and Vista) when >96 dpi is selected and "use XP style dpi scaling" is selected. If xp style scaling is not selected then I understand Win7 uses DPI virtualization instead. Everything looks fine when using DPI virtualization (Ok things are blurry but at least they're correct). By default in Win7 120 dpi uses xp style scaling and the next setting (144 dpi) does not. So our app looks correct at 144 dpi but wrong at 120 dpi.
If I edit the applications manifest to declare the app as "DPI aware" then this turns of DPI virtualization (but not XP style dpi scaling) and this gets me no where. Things still look really bad (no change for 120 dpi, 144 dpi now broken).
I need to fix this problem and I've tried reading up on DPI/scaling issues in general and it has been a learning experience. So far I have not found a suitable solution. At the moment I currently have no intention of doing a thorough and correct fix (the app correctly scales all elements according to the dpi). That would involve a LOT of rewriting. I think there are really two possible solutions. One is turn off any sort of DPI scaling all together. That would mean that if a users Win7 system was set to 120 dpi then everything on their system would look good/big but our app would look correct but would be small compared to everything else in other apps. The second solution would be to some how force our app to use DPI virtualization but to never use XP style dpi scaling. I want this to be an application side change and not rely on end users to have to make Windows configuration changes.
So far I have not found a way to accomplish either solution.
Can someone more knowledgeable on this subject please respond and point me in the right way?
Thanks
You cannot force DPI Virtualization on 120 DPI settings. I have investigated this for a product myself because having the fuzzy look in high DPI seemed a good tradeoff.
We ended up making a full rewrite of the UI positioning and scaling to have it scale properly with the font scaling in high DPI settings. The client is now fully DPI aware and scales properly in any DPI setting.
The work to do this properly took one guy ~3 months in our case for a pretty complex client.
We had a secondary plan that we never tried but it might work for you:
At start-up read the DPI scaling factor of the OS. Then reduce all font instances you have by this factor so that when Windows scales the fonts up again they are back at the size where the UI can fit them. Of course users with high DPI settings will not get bigger fonts in your application but it will at least be usable.
Today, I installed Visual Studio 2010 Professional on a new laptop with a fresh Windows 7 Ultimate 64-bit install. I, being quite used to the look of Visual Studio 2010, instantly spotted that something was wrong. It seems that the Visual Studio application is "zoomed in", in a way. The text is much larger (even though it says that the zoom level is 100%, and the text size is 10, which is the same as what I used before), and generally, so are the other windows like the Solution Explorer and Output console. The quality of the icons and images is also very bad.
Here are two comparison images (I wasn't allowed to post images, so some links will have to do):
This is the look that I'm used to. I see plenty of text in the windows, and the icons are fine.
http://i51.tinypic.com/2mq8dau.png
This is what greeted me when I installed VS2010 on my new laptop. The icons look stretched, and I can fit a lot less code in the window.
http://i56.tinypic.com/35k0fo4.png
The screen resolution on my old computer is 1920x1200 and the resolution on my new computer is 1920x1080. (I resized the VS window on my old computer to about 1920x1080 to show the difference).
It looks like my image host resized the images as well, but you should still be able to see the difference.
Has anyone had the same problem? I'm hoping it's just some visual settings. If anything is missing, I will be happy to provide more information.
Thanks in advance.
It seems your Font Size DPI is at 150% on the second screenshot. If you right click on the Desktop and select Personalize > Adjust Font Size (DPI)* you should be able to see what it is currently set at.
Check
that your screen is at native resolution (there can only be one, the native max)
that your OS font is
at normal size
antialiasing (i believe windows calls that cleartype or something)
the screen density is 'standard' (usually 96DPI IIRC)
I strongly suspect the latter (the DPI setting). It's under
Desktop Properies
Display Properties
Display Settings
Advanced
DPI Settings
in my Windows
If you hold down Ctrl and roll the wheel on the mouse it will zoom it in and out. You can then get the desired size that you want. I hope that solves it.
EDIT:
Also if you go to Tools->Options and then under Environment->Font and Colors you can then customize the font size for the whole application.
I didn't find any setting that could case this effect.
Did you try reseting the settings of visual studio (Tools - Import and Export Settings) or Import the settings of your working maschine.
Maybe you have configured big-icons / big-font in windows?
I've learn how to manage different DPI settings the hard way, so that at runtime my applications are properly displayed.
But there is still a big issue with Design time Visual Studio.
Say I build an application at 96 dpi and I switch my display to 120 dpi for testing purposes.
Now IF I open a form designer at 120 dpi, the form is resized according to 125%, the controls moved aso! :-(((
So I try to avoid reopening forms, but that's NOT a nice solution, isn't it?
Is there by any chance a design time setting to prevent form to resize?
Not a solution but possibly a workaround: do not test on your computer but on a VM or other computer and do not open the solution on a computer with big fonts.
And we found that we cannot use the AutoScaleMode = Dpi.Font setting. That will randomly resize forms when we open them in the designer. Dpi or None seem to work.
Although this question is already old, I want to share my workaround.
Keep the Form’s AutoScaleMode = Font. This works fine, if you control the rest correctly.
Set in your Forms Designer: Font = MS Sans; 11px. Basically, specify your Fonts in Pixel, instead of Points. So Visual Studio won't re-scale anything if the system's DPI change.
In the Forms Ctor, after InitializeComponent, re-set: Font = SystemFonts.DefaultFont. Now, at run time, Fonts will use Point-based sizes again, and you get nice high-DPI GUI.
Enable DPI-Awareness, either through a manifest or by API function SetProcessDPIAwareness
You can find the details of my (hard) learning trail on my Blog: http://www.sgrottel.de/?p=1581&lang=en
I really hope someone can help me here. I have tried applying SP1 to Visual Studio 2008 and SP1 to Crystal Reports Basic that comes with VB2008 to repair this problem, but have had no success. I've tried setting margins, changing paper sizes and default printers too.. No joy.
Every time I create a ReportViewer and give it a ReportDocument in Windows 7, the report isn't centered in the ReportViewer. If I resize the width of the window to the point you can see the whole page of the report, theres a huge section of background to the left. I was originally coding under Windows XP (the error doesn't occur in XP but does occur on some client systems running Windows 7), but after swapping my coding environment over to Windows 7 this error even occurs at design stage! Please help if you can.
Screenshot:
http://i55.tinypic.com/53o135.jpg
As you can see in this screenshot, there is no Crystal Report Viewer background visible on the right, yet there is already a large section visible on the left. Once the window is enlarged further, the left becomes even larger still.
I'm using Crystal XI under Windows XP, but I think I can answer your question.
In the image below (taken from your image), the white space circled in red holds your Group Tree. Click on the icon above it (with the red arrow) to hide the group tree.
The grey space (circled in green) tells you the Section Names, i.e. Header, Group Footer, etc. To turn that off, go into File->Options->Layout.
Does this answer your question, I hope? Oh, and welcome to StackOverflow :)
OK, I found the solution to this problem. It's when the user selects 120% magnified objects in their Windows Display settings! You need to adjust things for the DPI change