DPI Awareness

Using (or providing) components based on the "Win32" framework

DPI Awareness

Postby paulmansour on Fri Aug 21, 2015 9:52 pm

Ok, so I finally get 14.1 installed.

The DPI awareness enhancements look pretty good... except, the toolbar icons in the APL sessions (and in my app) as well as icons for tree views, etc,) do not scale. I don't think they are supposed to scale, so I don't think it is a Dyalog problem (well it IS a Dyalog problem for the APL Session - but not for my app.) I think it is a developer problem - that is my problem for my app.

This is a problem that Scott Hanselman has discussed here:


He notes that going half way with DPI awareness can be worse than being totally unware, where a 200% increase in everything, icons included, is not bad - though of course somewhat pixelated.

Anyway, what is the solution here? I imagine it is not trivial, or Dyalog would have the session icons and the explorer icons looking good at 200%.

Posts: 340
Joined: Fri Oct 03, 2008 4:14 pm

Re: DPI Awareness

Postby paulmansour on Sat Aug 22, 2015 8:26 pm

So further research shows you need to have a set of icons for the four standard screen scaling settings: small (100% of 96 dpi), medium (125%) large (150%) and larger (200%). I think most icons sets come in the necessary sizes. One then needs to know which one to use. I imagine you can get the necessary info from .NET, but it gets a bit complicated when the screen resolutions settings are done while the app it up. Now you have to listen for an event. Windows itself cheats a bit here, and re-sizes some stuff right away, but requires logoff to get other things (desktop icons) to re-size. Then, in windows 8.1, you can have a multi-monitor situation, each with its own resolution. Yikes.

It all seems so... primitive. It seems like a big kluge when one has to have a specific list of DPIs that you can work with...

I assume WPF gets around all this. I assume in WPF one specifies physical dimensions for a control, and then it renders it appropriately on the given device. So it you want a button to be 1 inch square, you specify that and that's the way it shows up on any screen. A while back I tried designing in "Dialog Units", by determining the height of the system font, but these seem to have fallen out of favor. But this brings up another question. How do all these different high DPI techniques interact? Does a WPF app get bigger and smaller too when you change the screen resolution settings? Is the "change the size of all items" feature of windows just for old pixel based apps, or for new WPF apps too? What happens when you have one WPF form along with all your ⎕WC forms?

Please forgive my rambling weekend thoughts on this. Any ones two cents appreciated.
Posts: 340
Joined: Fri Oct 03, 2008 4:14 pm

Re: DPI Awareness

Postby PGilbert on Sat Aug 22, 2015 11:51 pm

Hello Paul, here is what we have learned so far while using WPF regarding your topic:

1. WPF will take care of the DPI and a button will always look the same size if your customers are not using the same DPI as yours.

2. In WPF you need to make all your controls anchor properly so they will expand when your customer will resize your application. It is better not to use any 'margin' or 'padding' and let all the controls 'float' in their containers.

3. It is better to 'vectorized' all your icons and bitmaps, that way they will always look good on any screen.

4. If your customer 'resize' your application because it has a screen with a lot of pixels and want to make it look bigger you will need to capture that event and change the default font size of the window. Surprisingly WPF will not do that automatically. Everything will be resize properly but the font size will be too small. This is a trial and error process to find to correct multiplicator of the height of the window to the font height. The event to capture on the main window is 'SizeChanged' and you look at the 'ActualHeight' of that window and change the default 'FontSize'.

5. There is a 'Viewbox' control in WPF that will resize everything in it when your customer resize your application but it is just increasing the size of the pixels. You are better with increasing the size the default size of the font of the window.

User avatar
Posts: 393
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: DPI Awareness

Postby Vince|Dyalog on Tue Aug 25, 2015 4:03 pm

Hi Paul,

Thanks for you report and your research.

I'll tell JD about this.


Posts: 329
Joined: Wed Oct 01, 2008 9:39 am

Re: DPI Awareness

Postby JohnD|Dyalog on Mon Oct 12, 2015 11:20 am

Hello Paul and Pierre,

The problem with scaling bitmap images (which is how our session icons are saved) is that they just don't scale well. As you've mentioned Paul, the correct approach is to provide images at various scaling factors and slot in the appropriate images at runtime. Unfortunately we didn't get a new set if images in time for the 14.1 release, so our icons do look a little "naff" at higher DPIs. We're going to address this in 15.0, and possibly have a new "theme" for the icons too.

Best Regards
User avatar
Posts: 64
Joined: Wed Oct 01, 2008 9:35 am

Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest