LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing DPI Virtualization

Hi,

 

Is there a way to get a CVI application to use "DPI Virtualization" in Windows Vista and later?  DPI Virtualization is a compatibility thing where Windows will render the application window as a bitmap at 96 DPI and then enlarge the bitmap to match the current DPI setting.  This unfortunately results in the window being blurry, but this would be preferable to what is happening now where I have text and UI elements overlapping each other due to the increased font size.  I could fix the application, but this is a rather large application and CVI's UI editor doesn't really lend itself to this kind of thing anyway. 

 

From my understanding of how this works, Windows will do DPI Virtualization automatically unless the application specifically states that it is DPI aware.  This is assuming the "use XP style DPI scaling" option is not checked in Control Panel (which it isn't).  Now, my application is not calling any of the Windows API functions like SetProcessDPIAware() or stating that it is DPI aware in the manifest, yet Windows is treating the application as if it is DPI aware. So I'm assuming that the CVI runtime engine is doing this for me.  Is that the case?  If so, is there a way to make it so that it doesn't do this?

 

Thanks.

0 Kudos
Message 1 of 11
(8,439 Views)

Hi tstanely,

 

The LabWindows™/CVI™ ADE is DPI aware, but this should not be passed to written applications. As far as I know, the run-time engine does not apply DPI awareness to built applications. If you don't mind, how did this issue come up?

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 2 of 11
(8,389 Views)

Hi Steven,

 

Thanks for the reply.  This has come about because people are installing my application on some of the newer laptops that feature a higher resolution, smaller screen where they have the font size set to medium or large in Windows (some of them come this way from the vendor). This increases the font size in my application, but the problem is that with CVI where the UI is laid out on a "pixel perfect" basis, the application doesn't take well to the font size increasing (the ADE itself seems to handle it just fine).  So I end up the overlapping controls, control labels on the top of controls, buttons that grow awkwardly, etc.  And no matter what I seem to try, I can't seem to make this behavior change.  I can set the DPI awareness in the manifest to false, and I'm not calling any of the Windows API functions that tell Windows that an application is DPI aware, but Windows still treats my application as if it is DPI aware so my only guess at this point is that it's something the CVI runtime engine does.  It's basically the situation described on this page http://www.kynosarges.org/WindowsDpi.html for "Applications without DPI awareness that set the DPI-aware flag". 

 

Playing around with it a bit, I've just realized that CVI could potentially handle this in a nicer manner with little work needed by the developer by utilizing the functionality that the "Scale Contents on Resize" uses for panels.  Since that option scales everything (not just the fonts), if the runtime engine would essentially render the panel for 96 DPI, set this flag then increase the window size by 25% (for 120 DPI setting) then the application would look correct, including fonts, in a high DPI mode without the need for DPI virtualization.

 

 

0 Kudos
Message 3 of 11
(8,367 Views)

I realize this isn't exactly what you are looking for, but have you seen this discussion? It seems like the resolution adjustment option might be what you are looking for. Unfortunately there's not much more information on DPI awareness with LabWindows™/CVI™ beyond what I told you in the previous post. 

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 4 of 11
(8,343 Views)

Hi Steven,

 

I tried monitoring what's going on behind the scenes with APIMonitor and Dependency Walker, and there is a call from cvirte.dll to SetProcessDPIAware which is kind of what I suspected.  In my opinion that call should not be there, allowing the programmer to handle (or not handle) DPI scaling as they see fit for their application.  I'll add a suggestion to the Idea Exchange.

 

As for that other discussion, that is not really what I'm looking for.  I could use that to make the fonts bigger in my application, but Windows would still have to be set to 96 DPI and the users want to be able scale the fonts system-wide.

 

Thanks for the help.

0 Kudos
Message 5 of 11
(8,323 Views)

There might be an INI token available to set the DPI Awareness, but I haven't been able to find any. I know past users have had to create a second UIR and dynamically select which one to load. Again, I realize this is not a great answer. I'll see if I can't find an INI token.

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 6 of 11
(8,292 Views)

Is it possible to read the windows test resize value while you are in the CVI application?  If not is there an easy way to determine what it is set at when the application is opened?

Thanks,

Blake

0 Kudos
Message 7 of 11
(5,429 Views)

Hi Blake,

 

Are you trying to determine the panel size? If so, you can call the GetPanelAttribute function and get the height/width.

 

Since this thread is somewhat old. I think it is a good idea to start a new post. People tend to look at newer posts more often.

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 8 of 11
(5,411 Views)

Hi Ren,

No, I am trying to determine what the "Change the size, apps, and other items" percentage in Windows 10 "Display / Customize your display" is set to.  100% to 300% is the typical range.  With all the new 4k monitors being sold now, if you use a "META" font in CVI windows will make it larger which is a major problem in the UIR if it is in a button or almost anywhere.  It blows up the 3Dgraphs, it explodes the menu bars and all of the panels get overwritten by the menu bar.  I am trying to figure out what this is set to so, I can have the program move the panels and adjust everything including 3D panel size so that the functions can be used.  Currently I am looking at the monitor height and guessing at what the size of text percentage is set to.  This is a big pain in the rear.  I bought a 4k laptop myself to try to get this working.  I have tried to read the ATTR_MENU_BAR_LABEL_FONT_SIZE (I am not at that computer, this could be incorrect) to see if I can determine where this percentage is set to, so far all I get is garbage.  I am now trying the ATTR_MENU_BAR_HEIGHT command but, I haven't tried it on the 4K screen yet.  Hoping...

Thanks,

Blake 

0 Kudos
Message 9 of 11
(5,393 Views)

Blake,

 

In terms of gettings the Windows display settings, I don' think CVI doesn't have a function that do that, but Windows SDK should have something that does that. The idea is similar to this KB. You will need to find the right Windows function to call.

 

Can you attach a screencap of display looks like? I'm not sure if you are having an issue similar to this forum post, but changing the Windows Registry seems to be the workaround. If that doesn't work, I really encourage you making a new post with the screencap of your issue, as they tend to gain a lot more attraction than older ones. 

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 10 of 11
(5,383 Views)