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?
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.
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....
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
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:
VB and WinForm does not have the ability to turn of DpiAwareness
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.