v17 (Final) BUG XAML DPIAware
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=22841
Printed Date: 25 December 2024 at 1:22am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: v17 (Final) BUG XAML DPIAware
Posted By: MacW
Subject: v17 (Final) BUG XAML DPIAware
Date 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.
|
Replies:
Posted By: MacW
Date 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.
|
Posted By: MacW
Date 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.
|
|