in Apps

Handle projectors when using actual size in your app


In a previous post, Using Actual Size in your Windows 8.1 app, we talked through step-by-step how to build an app that displays content with consideration of the actual screen size. Since then, I was demoing my awesome RealRuler app, and it didn’t work on the projector.

Screen size info can be zero

As good as the post was, it left out one important case: projectors. When you project a Windows 8.1 PC and duplicate your screen, Windows doesn’t know which screen to give you the pixel density of, so it gives you zero. Even if you aren’t duplicating your screen, many projectors, and older monitors don’t provide accurate display size information through their EDID, so it’s a good error case to handle anyway.

Handle it

It’s simple enough to handle this case, just check if the returned value is greater than zero.

var info = Windows.Graphics.Display.DisplayInformation.getForCurrentView();
if (info.rawDpiX > 0) {
    // Do the actual size stuff
} else {
    // Fake it till you make it, or fail out

Updated RealRuler code


I submitted an update to RealRuler published on the Windows Store, and updated the code published on github for you. Go check it out if you want to see how I simulate screen size when it’s not available.



Write a Comment