From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read and Write WIndows Display Scaling from LabVIEW

Solved!
Go to solution

Has anyone implemented Windows calls from LabVIEW to read and change the Windows Display Scaling?

 

TIA

DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 6
(3,034 Views)

What are you trying to do exactly?

Benoit

0 Kudos
Message 2 of 6
(2,890 Views)

The smart-a** answer: I'm trying to change the display scaling in Windows from LabVIEW.

Perhaps a more informative answer: My client bought a Surface with 1800 x 1200 res, but the screen is only 10". (Seems like less. It's really small.) (This would be a great place to interject Michael's running joke from the Office, but I'll refrain...) (Does that count as refraining?) To run any normal Windows program, it's best to leave the scaling at 150%. But  LabVIEW doesn't play well with the scaling factor, and I've already spent a lot of time laying out the UI to fit 1800 x 1200. So I'd like to have the laptop configured for 1800 x 1200 with 150% scaling, then have my program change the scaling to 100%. When my program exits, I would set it back to whatever it was before my program started, hence the need to be able to read as well as write the scaling factor. In case the end user decided to change the scaling for his/her other apps.

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 6
(2,874 Views)

I guess this would only work well if that was the only application the user was running at the time.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 6
(2,870 Views)
Solution
Accepted by Dave_Thomson

From my limited research some time ago, Microsoft really does not want an application to be able to mess with that system setting. From a system perspective this is quite understandable as if they start to document any API to to that, every half baked programmer will feel eligible to change that setting at will.

 

And that can really mess with application on a system depending if they are DPI aware or not. Actually it will mess in any case with applications but in different ways, depending on their DPI awareness. LabVIEW being fully not DPI aware in any way is at one extreme of that scale, while other applications being partly or fully DPI aware are affected in even worse ways when the DPI scaling changes as they will autimatically try to adjust to that, more or less successfully depending on their awareness. Unpretty effects are unavoidable during the switch and some may remain after for such applications.

 

You may rather want to play with the process DPI aware setting for your LabVIEW application instead of changing that system setting. There is an API SetProcessDpiAwarenessContext() that lets you change the setting for the current process. LabVIEW is by default DPI unaware and hence Windows will scale its Windows with the DPI scaling factor automatically. Lieing to Windows that your LabVIEW process is DPI aware, either system DPI aware or even per monitor will tell Windows to not scale any LabVIEW Windows. But above mentioned API has one drawback, at the time your LabVIEW application gets a change to call it, it most likely has already called various Windows graphic IO functions and Windows has determined the DPI mode already and you can't change that mode after it has been set once. Microsofts solution for that is to rather use a manifest file. For LabVIEW you can do that by placing a MyApp.manifest file with the necessary contents into the same directory as your executable.

 

See here about the process. This method has the advantage that it does not mess with your users system settings.

Rolf Kalbermatter
My Blog
Message 5 of 6
(2,855 Views)

Thanks for the info, Rolf. Much appreciated, as always.

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 6 of 6
(2,847 Views)