Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - v17 (Final) BUG XAML DPIAware
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

v17 (Final) BUG XAML DPIAware

 Post Reply Post Reply
Author
Message
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Topic: v17 (Final) BUG XAML DPIAware
    Posted: 12 January 2016 at 5:26am
I use XAML a lot for the UI and also for printing., metafiles etc.

So far I had to scale the font sizes manually if the output DC was not using 96 DPI.

Version 17 brought us the SetDPIAware option for the XTPMarkupContext. But is is severely flawed.

All my print layouts were plain wrong. So I stepped into your code and finally found the method (static of a singleton, no way to override or fix for me)

void CXTPDpi::Init()

which uses GetDC(NULL)  to retrieve a device context to base the DPI calculations on.

This is wrong for several reasons:

1. What if your code is used on a system with multiple monitors, with different DPI settings?
2. What if your code is used with a DC that is not at screen DPI (Metadatafile, Printing, Bitmap)

Your code needs to use the device context used with XTPMarkupRenderElement(...) to determine the DPI to use for font and measurement scaling. Currently you resolve everything in Parse() but that cannot work. At least Parse must take a HDC so you have access to the DPI of the device context which will be used for rendering.

Make this an optional parameter to not break existing code.
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2016 at 7:32am
In addition:

On my 4K monitors (3940 pixel) with font-scaling set to 150%, calling GetDeviceCaps on a hdc returned by GetDC(NULL) returns 96 DPI.

When you instead use a real device context for a real window (MainFrame.cpp):

    CClientDC dc(this);
    int lpy = dc.GetDeviceCaps(LOGPIXELSY);

you get the correct 144 DPI.

Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2016 at 7:53am
And something else must have change too because markup in device contexts with more than 96 DPI is rendered wrong.

For the previous XTP., my code parsed the markup written by the user and replaced font sizes given in "pt" to match the actual DPI of the device context.

XTP assumes 96 DPI so when my code sees

"10pt"

for a device context mit 360 DPI, it replaces this with

"38pt"

This worked for the versions before 17, but now XTP either renders a much too large font when the output DC is 150 to 360 and no output at all when the output device context has 600 DPI. Unfortunately this is the standard (and only) resolution of the PDF printer built into Windows 10.

I have a hunch that this is also because of your hard-coded 96 DPI setting with GetDC(NULL). It was better before, when you did not try to be DPIAware.

The only way I see at this time is to roll back my code to the last "16" version of XTP.

Note: I think the clipped tooltips I have reported in my other post, and the partially clipped texts in TaskDialogs may have the same reason. I (and most of my users) run my software on monitors with DPI settings larger than 96 pixels.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.