Turn off DPI Awareness in .NET VS2010 Windows Forms application


Is there anyone who has knowledge how to turn off the DPI Awereness in a VB.NET VS2010 Windows Forms application?

I found lots of articles for VS2008 and C# but non of theese works for VS2010 while its totally different properties and app.manifest file does not look the same nowdays.

I just want to turn of the DPI scaling that is done when the user has 125% or 150% of the font in Vista and Windows 7.
Our application does not need to scale up.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try setting the AutoScale mode to "None".  Other choices are "Font", "Dpi", and "Inherit".
cynkanAuthor Commented:
Yes, that works for just that form size, not the controls inside it.
A button has no AutoScaleMode so it does not work all the way to turn it off.

Check http://msdn.microsoft.com/en-us/library/windows/desktop/dd464660(v=vs.85).aspx and further down under "Using an Application Manifest" and you see how to turn off this completly for the application. This is what I am trying....
I searched through MSDN, because I've not had this issue in the past.  Previously, any issue I had with scaling was solved with the property I referred to above.

My search brought me to this:

MSDN Forum: Odd results...

After reading through this and following a few links, I ended up here:

SetProcessDPIAware function

The function itself is likely not available to you, as you are writing in VB, and the function is C++/WINAPI.  The instructions halfway down the page, about changing the manifest may or may not be what you have done.  The instructions are to change the manifest by adding an xml tag <dpiAware>, which is about half way down the page.  The page also implies that this alteration doesn't work in class library or module projects (which create dll output), which I doubt is your problem.

Additionally, you may need to create your own manifest completely.  To do that, you need to right click on the project name in the solution explorer window, then choose "Add".  In the next window, select "Application Manifest File" with whatever name you desire.  Make certain to add the tag described in the second link above.

All the best, as always.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

cynkanAuthor Commented:
Thanks for theese urls. I read many many pages, first you provided I have´t found erlier.
Major problem is that everyone talking about how to make good DPI scaling, not how to turn it off completly.
Same with the page http://msdn.microsoft.com/en-us/library/ms229605.aspx, it also explain everything around how to scale, not how to not scale ;)

I tried the SetProcessDPIAware function but same there, it turns it on :(

What I believe and hope for is to get the <dpiAware> switch to work wich I also tried to get to work in VB but here I have´t found any sample showing how.
In VB.NET there is no way to add your own manifest file, we have to use the app.manifest (as I understand it) as you see in my picture below. The button "View Windows Settings" is all we have in VB.

So what I tried before was to add the <asmv3:application> section and set it to false. No errors but still scaling :(

All the best to you too and many thanks for trying to clear the "forest" of all this ;)
Another XML type file that may help is the "Application Configuration File" (ACF) type.  I would also try the <dpiAware> tag using both true and false.  While the article implies it should be set to true, I've found that, sometime, MS examples show one thing, but you need to do the exact opposite to get the results you want.

If you add the ACF, I would place the dpiAware tag directly under the <system.diagnostics> switch.  It could also be that you will need to add tags for WINAPI and then add the <dpiAware> tag.

I also want to add that it is generally frustrating that the file types aren't the same across all languages.  The custom manifest seems to only be available in C#...sorry about that.
cynkanAuthor Commented:
Hehe, yes MS samples are not always easy ;)
Your idea with ACF was good, unfortunly it does´t seems to fit with <dpiAware> tag anyware. Tested a lot of combinations. Probably it´s another tagname or something...

Some of my friends think this <dpiAware> is only for WPF as the SetDPIAwareness is.
I think I will email my contacts at MS to see if there is a way in WinForms and VB.
The link I provided implies that SetProcessDPIAware is a C++/WINAPI function, probably part of the old MFC libraries or the Win32 API.  I'm honestly surprised that this isn't in the .NET library, which I thought subsumed the MFC/Win32 API.  Like you, I haven't been able to find anything in the .NEt docs that allows for a call of this nature.

One other property that may help is the "Locked" property, which is part of every control.  When a control is locked, it's not supposed to be able to move or resize.  This could also prevent the scaling issue you're seeing.  The down side is that the control is locked in place, so resizing the window will still cause the control to be frozen.

cynkanAuthor Commented:
Unfortunly there seems not to be any solution for WinForm and VB and I give up my investigations.
I rebuild some controls and made some panels scrollable so the user can see them completely.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cynkanAuthor Commented:
VB and WinForm does not have the ability to turn of DpiAwareness
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.